@hyperdreamer/pi-webui 1.8.0 → 1.9.0
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 +1 -1
- package/dist/client/assets/{CodeViewer-DWIKbHl0.js → CodeViewer-Bpvsp0pk.js} +1 -1
- package/dist/client/assets/{UnifiedDiffViewer-BSrL6IvO.js → UnifiedDiffViewer-iSh_gYQc.js} +1 -1
- package/dist/client/assets/{index-CrFrPrnQ.js → index-DCPkewJK.js} +427 -435
- package/dist/client/index.html +1 -1
- package/dist/server/app.js +1 -8
- package/dist/server/app.js.map +1 -1
- package/dist/server/models/modelsConfigService.js +1 -1
- package/dist/server/models/modelsConfigService.js.map +1 -1
- package/dist/server/sessions/authService.js +3 -3
- package/dist/server/sessions/authService.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +3 -3
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionDefaultsService.js +1 -1
- package/dist/server/sessions/sessionDefaultsService.js.map +1 -1
- package/package.json +7 -7
- package/dist/server/browser/browserCapabilities.js +0 -74
- package/dist/server/browser/browserCapabilities.js.map +0 -1
- package/dist/server/browser/browserCapabilityRoutes.js +0 -34
- package/dist/server/browser/browserCapabilityRoutes.js.map +0 -1
- package/dist/server/browser/browserPolicy.js +0 -382
- package/dist/server/browser/browserPolicy.js.map +0 -1
- package/dist/server/browser/browserRuntime.js +0 -16
- package/dist/server/browser/browserRuntime.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeViewer-Bpvsp0pk.js","./vendor-editor-core-vUi74DnD.js","./vendor-editor-languages-DoaXUodB.js","./vendor-editor-legacy-CYBnW6ZU.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{$ as e,A as t,J as n,P as r,Q as i,S as a,X as o,Z as s,d as c,f as l,j as u,l as d,p as f,q as p,u as m}from"./vendor-editor-core-vUi74DnD.js";import{a as ee,o as te,s as ne}from"./vendor-editor-languages-DoaXUodB.js";import{n as re,t as ie}from"./vendor-terminal-D8k4UKM2.js";var ae=Object.defineProperty,oe=(e,t)=>{let n={};for(var r in e)ae(n,r,{get:e[r],enumerable:!0});return t||ae(n,Symbol.toStringTag,{value:`Module`}),n};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var se=globalThis,ce=se.ShadowRoot&&(se.ShadyCSS===void 0||se.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,le=Symbol(),ue=new WeakMap,de=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==le)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(ce&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=ue.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&ue.set(t,e))}return e}toString(){return this.cssText}},fe=e=>new de(typeof e==`string`?e:e+``,void 0,le),h=(e,...t)=>new de(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,le),pe=(e,t)=>{if(ce)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=se.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},me=ce?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return fe(t)})(e):e,{is:he,defineProperty:ge,getOwnPropertyDescriptor:_e,getOwnPropertyNames:ve,getOwnPropertySymbols:ye,getPrototypeOf:be}=Object,xe=globalThis,Se=xe.trustedTypes,Ce=Se?Se.emptyScript:``,we=xe.reactiveElementPolyfillSupport,Te=(e,t)=>e,Ee={toAttribute(e,t){switch(t){case Boolean:e=e?Ce:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},De=(e,t)=>!he(e,t),Oe={attribute:!0,type:String,converter:Ee,reflect:!1,useDefault:!1,hasChanged:De};Symbol.metadata??=Symbol(`metadata`),xe.litPropertyMetadata??=new WeakMap;var ke=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Oe){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&ge(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=_e(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Oe}static _$Ei(){if(this.hasOwnProperty(Te(`elementProperties`)))return;let e=be(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Te(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Te(`properties`))){let e=this.properties,t=[...ve(e),...ye(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(me(e))}else e!==void 0&&t.push(me(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return pe(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?Ee:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?Ee:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??De)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};ke.elementStyles=[],ke.shadowRootOptions={mode:`open`},ke[Te(`elementProperties`)]=new Map,ke[Te(`finalized`)]=new Map,we?.({ReactiveElement:ke}),(xe.reactiveElementVersions??=[]).push(`2.1.2`);var Ae=globalThis,je=e=>e,Me=Ae.trustedTypes,Ne=Me?Me.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Pe=`$lit$`,Fe=`lit$${Math.random().toFixed(9).slice(2)}$`,Ie=`?`+Fe,Le=`<${Ie}>`,Re=document,ze=()=>Re.createComment(``),Be=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Ve=Array.isArray,He=e=>Ve(e)||typeof e?.[Symbol.iterator]==`function`,Ue=`[
|
|
3
3
|
\f\r]`,We=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ge=/-->/g,Ke=/>/g,qe=RegExp(`>|${Ue}(?:([^\\s"'>=/]+)(${Ue}*=${Ue}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Je=/'/g,Ye=/"/g,Xe=/^(?:script|style|textarea|title)$/i,Ze=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),g=Ze(1),_=Ze(2),Qe=Symbol.for(`lit-noChange`),v=Symbol.for(`lit-nothing`),$e=new WeakMap,et=Re.createTreeWalker(Re,129);function tt(e,t){if(!Ve(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Ne===void 0?t:Ne.createHTML(t)}var nt=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=We;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===We?c[1]===`!--`?o=Ge:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=qe):(Xe.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=qe):o=Ke:o===qe?c[0]===`>`?(o=i??We,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?qe:c[3]===`"`?Ye:Je):o===Ye||o===Je?o=qe:o===Ge||o===Ke?o=We:(o=qe,i=void 0);let d=o===qe&&e[t+1].startsWith(`/>`)?` `:``;a+=o===We?n+Le:l>=0?(r.push(s),n.slice(0,l)+Pe+n.slice(l)+Fe+d):n+Fe+(l===-2?t:d)}return[tt(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},rt=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=nt(t,n);if(this.el=e.createElement(l,r),et.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=et.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Pe)){let t=u[o++],n=i.getAttribute(e).split(Fe),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?ct:r[1]===`?`?lt:r[1]===`@`?ut:st}),i.removeAttribute(e)}else e.startsWith(Fe)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Xe.test(i.tagName)){let e=i.textContent.split(Fe),t=e.length-1;if(t>0){i.textContent=Me?Me.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],ze()),et.nextNode(),c.push({type:2,index:++a});i.append(e[t],ze())}}}else if(i.nodeType===8)if(i.data===Ie)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(Fe,e+1))!==-1;)c.push({type:7,index:a}),e+=Fe.length-1}a++}}static createElement(e,t){let n=Re.createElement(`template`);return n.innerHTML=e,n}};function it(e,t,n=e,r){if(t===Qe)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Be(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=it(e,i._$AS(e,t.values),i,r)),t}var at=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??Re).importNode(t,!0);et.currentNode=r;let i=et.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new ot(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new dt(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=et.nextNode(),a++)}return et.currentNode=Re,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},ot=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=v,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=it(this,e,t),Be(e)?e===v||e==null||e===``?(this._$AH!==v&&this._$AR(),this._$AH=v):e!==this._$AH&&e!==Qe&&this._(e):e._$litType$===void 0?e.nodeType===void 0?He(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==v&&Be(this._$AH)?this._$AA.nextSibling.data=e:this.T(Re.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=rt.createElement(tt(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new at(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=$e.get(e.strings);return t===void 0&&$e.set(e.strings,t=new rt(e)),t}k(t){Ve(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(ze()),this.O(ze()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=je(e).nextSibling;je(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},st=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=v,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=v}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=it(this,e,t,0),a=!Be(e)||e!==this._$AH&&e!==Qe,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=it(this,r[n+o],t,o),s===Qe&&(s=this._$AH[o]),a||=!Be(s)||s!==this._$AH[o],s===v?e=v:e!==v&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===v?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},ct=class extends st{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===v?void 0:e}},lt=class extends st{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==v)}},ut=class extends st{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=it(this,e,t,0)??v)===Qe)return;let n=this._$AH,r=e===v&&n!==v||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==v&&(n===v||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},dt=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){it(this,e)}},ft={M:Pe,P:Fe,A:Ie,C:1,L:nt,R:at,D:He,V:it,I:ot,H:st,N:lt,U:ut,B:ct,F:dt},pt=Ae.litHtmlPolyfillSupport;pt?.(rt,ot),(Ae.litHtmlVersions??=[]).push(`3.3.3`);var mt=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new ot(t.insertBefore(ze(),e),e,void 0,n??{})}return i._$AI(e),i},ht=globalThis,y=class extends ke{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=mt(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Qe}};y._$litElement$=!0,y.finalized=!0,ht.litElementHydrateSupport?.({LitElement:y});var gt=ht.litElementPolyfillSupport;gt?.({LitElement:y}),(ht.litElementVersions??=[]).push(`4.2.2`);var b=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},_t={attribute:!0,type:String,converter:Ee,reflect:!1,hasChanged:De},vt=(e=_t,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function x(e){return(t,n)=>typeof n==`object`?vt(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function S(e){return x({...e,state:!0,attribute:!1})}var yt=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function C(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return yt(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return yt(n,r,{get(){return a(this)}})}}function bt(e,t=St()){let n=new URL(t.viteBaseUrl,t.documentBaseUrl);return new URL(Ct(e),n).toString()}function xt(e,t=St()){let n=new URL(bt(e,t));if(n.protocol===`http:`)n.protocol=`ws:`;else if(n.protocol===`https:`)n.protocol=`wss:`;else throw Error(`Cannot create a WebSocket URL from ${n.protocol}`);return n.toString()}function St(){return{viteBaseUrl:`./`,documentBaseUrl:document.baseURI}}function Ct(e){return e.startsWith(`/`)?`.${e}`:e}async function w(e,t,n){let r=new Headers(n?.headers);n?.body!==void 0&&!r.has(`content-type`)&&r.set(`content-type`,`application/json`);let i=await fetch(bt(e),{...n,headers:r});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(wt(e)??i.statusText)}return t(await i.json())}function wt(e){if(Tt(e))return typeof e.error==`string`?e.error:void 0}function Tt(e){return typeof e==`object`&&!!e}var T={sessionsDeleteArchived:`sessions.deleteArchived`,sessionsBulkMutations:`sessions.bulkMutations`,sessionsCleanup:`sessions.cleanup`,sessionsReload:`sessions.reload`,sessionsClearQueue:`sessions.clearQueue`,sessionsMessageActions:`sessions.messageActions`,sessionsSystemPrompt:`sessions.systemPrompt`,sessionsPersistedState:`sessions.persistedState`,sessionsNotifications:`sessions.notifications`,sessionsUnread:`sessions.unread`,promptAttachments:`prompt.attachments`,workspaceFileSuggestions:`workspace.fileSuggestions`,piPackagesManage:`piPackages.manage`,selectedMachineSettings:`settings.selectedMachine`,agentProfileConfig:`settings.agentProfile`},Et=1e3,Dt=32*1024,Ot=8*1024,kt=1e4;function At(e){return(e.split(/[\\/]/u).at(-1)?.toLowerCase()??e.toLowerCase()).replace(/(?:\.[cm]?js|\.exe|\.cmd)$/iu,``)===`pi`}function jt(e){return!e.includes(`/`)&&!e.includes(`\\`)&&At(e)}var Mt=new Set([`schemaVersion`,`revision`,`command`,`dir`,`sessionDirEnvKeys`]),Nt=/^sha256:[0-9a-f]{64}$/u,Pt=/^[A-Za-z0-9_][A-Za-z0-9._+-]*$/u,Ft=new Set([`PI_WEBUI_AGENT_SESSION_DIR`,`PI_CODING_AGENT_SESSION_DIR`]);function It(e){if(!Vt(e)||Object.keys(e).some(e=>!Mt.has(e)))return;let t=e.schemaVersion,n=e.revision,r=e.command,i=e.dir,a=e.sessionDirEnvKeys;if(t===1&&!(typeof n!=`string`||!Nt.test(n))&&!(typeof r!=`string`||!Lt(r))&&!(typeof i!=`string`||!Rt(i))&&Bt(a)&&new Set(a).size===a.length&&!(a[0]!==`PI_WEBUI_AGENT_SESSION_DIR`||a.some(e=>!Ft.has(e))))return Object.freeze({schemaVersion:t,revision:n,command:r,dir:i,sessionDirEnvKeys:Object.freeze([...a])})}function Lt(e){return e!==e.trim()||/[\s;&|`$<>]/u.test(e)?!1:Rt(e)?!e.endsWith(`/`)&&!e.endsWith(`\\`):Pt.test(e)}function Rt(e){if(e===``||e!==e.trim()||zt(e))return!1;let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<32||e===127)return!0}return!1}function Bt(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function Vt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ht=Object.values(T),Ut=new Set(Ht);T.sessionsDeleteArchived,T.sessionsBulkMutations,T.sessionsCleanup,T.sessionsReload,T.sessionsClearQueue,T.sessionsMessageActions,T.sessionsSystemPrompt,T.sessionsPersistedState,T.sessionsNotifications,T.sessionsUnread,T.promptAttachments,T.workspaceFileSuggestions,T.piPackagesManage,T.selectedMachineSettings,T.agentProfileConfig,T.sessionsDeleteArchived,T.sessionsBulkMutations,T.sessionsCleanup,T.sessionsReload,T.sessionsClearQueue,T.sessionsMessageActions,T.sessionsSystemPrompt,T.sessionsPersistedState,T.sessionsNotifications,T.sessionsUnread,T.promptAttachments,T.sessionsDeleteArchived,T.sessionsBulkMutations,T.sessionsCleanup,T.sessionsReload,T.sessionsClearQueue,T.sessionsMessageActions,T.sessionsSystemPrompt,T.sessionsPersistedState,T.sessionsNotifications,T.sessionsUnread,T.promptAttachments,T.workspaceFileSuggestions,T.piPackagesManage,T.selectedMachineSettings,T.agentProfileConfig;function Wt(e){return typeof e==`string`&&Ut.has(e)}function Gt(e,t){return e?.capabilities?.includes(t)===!0}function Kt(e){if(!(!Array.isArray(e)||!e.every(e=>typeof e==`string`)))return e.filter(Wt)}function qt(e){return typeof e==`object`&&!!e}function E(e){if(!qt(e))throw Error(`Expected object response`);return e}function D(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Expected string field: ${t}`);return n}function O(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`string`)throw Error(`Expected optional string field: ${t}`);return n}}function k(e,t){let n=e[t];if(typeof n!=`number`)throw Error(`Expected number field: ${t}`);return n}function A(e,t){let n=e[t];if(typeof n!=`boolean`)throw Error(`Expected boolean field: ${t}`);return n}function j(e){return t=>{if(!Array.isArray(t))throw Error(`Expected array response`);return t.map(e)}}function Jt(e){if(!Array.isArray(e))throw Error(`Expected array response`);return e}function Yt(e,t){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`))throw Error(`Expected string array field: ${t}`);return e}function Xt(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};let t=E(e);return{messages:Jt(t.messages),start:k(t,`start`),total:k(t,`total`)}}function Zt(e){let t=E(e);return j(Qt)(t.machines)}function Qt(e){let t=E(e),n=tn(t,`kind`),r=O(t,`baseUrl`),i=nn(t,`status`),a=O(t,`statusMessage`);return{id:D(t,`id`),name:D(t,`name`),kind:n,...r===void 0?{}:{baseUrl:r},createdAt:D(t,`createdAt`),updatedAt:D(t,`updatedAt`),...i===void 0?{}:{status:i},...a===void 0?{}:{statusMessage:a}}}function $t(e){let t=E(e),n=nn(t,`status`),r=O(t,`error`);return{machineId:D(t,`machineId`),ok:A(t,`ok`),checkedAt:D(t,`checkedAt`),...n===void 0?{}:{status:n},...t.web===void 0?{}:{web:Bi(t.web)},...t.sessiond===void 0?{}:{sessiond:Bi(t.sessiond)},...r===void 0?{}:{error:r}}}function en(e){let t=E(e),n=O(t,`error`);return{machineId:D(t,`machineId`),ok:A(t,`ok`),checkedAt:D(t,`checkedAt`),...N(`packageName`,O(t,`packageName`)),...N(`generatedAt`,O(t,`generatedAt`)),...t.components===void 0?{}:{components:Ri(t.components)},...t.capabilities===void 0?{}:{capabilities:Ki(t.capabilities)},...n===void 0?{}:{error:n}}}function tn(e,t){let n=D(e,t);if(n!==`local`&&n!==`remote`)throw Error(`Expected machine kind field: ${t}`);return n}function nn(e,t){let n=O(e,t);if(n!==void 0){if(n!==`unknown`&&n!==`online`&&n!==`offline`&&n!==`error`)throw Error(`Expected machine status field: ${t}`);return n}}function rn(e){let t=E(e);return{id:D(t,`id`),name:D(t,`name`),path:D(t,`path`),createdAt:D(t,`createdAt`)}}function an(e){let t=E(e),n=O(t,`branch`);return{id:D(t,`id`),projectId:D(t,`projectId`),path:D(t,`path`),label:D(t,`label`),...n===void 0?{}:{branch:n},isMain:A(t,`isMain`),isGitRepo:A(t,`isGitRepo`),isGitWorktree:A(t,`isGitWorktree`),...N(`effectiveConfig`,on(t.effectiveConfig))}}function on(e){if(e!==void 0){if(!qt(e)||Array.isArray(e))throw Error(`Invalid workspace effectiveConfig field`);return{...N(`uploads`,di(e.uploads))}}}function sn(e){let t=E(e),n=O(t,`name`),r=Pi(t.persisted,`persisted`),i=O(t,`parentSessionPath`),a=O(t,`archivedAt`),o=Pi(t.pinned,`pinned`);return{id:D(t,`id`),path:D(t,`path`),cwd:D(t,`cwd`),...r===void 0?{}:{persisted:r},...n===void 0?{}:{name:n},created:D(t,`created`),modified:D(t,`modified`),messageCount:k(t,`messageCount`),firstMessage:D(t,`firstMessage`),...i===void 0?{}:{parentSessionPath:i},...t.archived===!0?{archived:!0}:{},...a===void 0?{}:{archivedAt:a},...o===void 0?{}:{pinned:o}}}function cn(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid session warning severity`);return e}function ln(e){if(e!==void 0)return{id:D(E(e),`id`)}}function un(e){let t=E(e),n=ln(t.dismiss);return{severity:cn(t.severity),message:D(t,`message`),...N(`source`,O(t,`source`)),...N(`path`,O(t,`path`)),...n===void 0?{}:{dismiss:n}}}function dn(e){return e===void 0?{}:{warnings:j(un)(e)}}function fn(e){let t=E(e);return{sessionId:D(t,`sessionId`),...N(`persisted`,Pi(t.persisted,`persisted`)),isStreaming:A(t,`isStreaming`),isCompacting:A(t,`isCompacting`),isBashRunning:A(t,`isBashRunning`),pendingMessageCount:k(t,`pendingMessageCount`),queuedMessages:t.queuedMessages===void 0?[]:j(qn)(t.queuedMessages),...N(`messageCount`,M(t,`messageCount`)),tokens:Jn(t.tokens),cost:k(t,`cost`),...Rr(t.generation),...Xn(t.model),...zr(t.contextUsage),...N(`thinkingLevel`,O(t,`thinkingLevel`)),...dn(t.warnings)}}function pn(e){let t=E(e);return{seq:k(t,`seq`),partial:t.partial??null}}function mn(e){let t=O(E(e),`systemPrompt`);return t===void 0?{}:{systemPrompt:t}}function hn(e){let t=E(e),n=Pn(t,`catalogRevision`),r=jn(t.sessions,_n,Et,`sessions`);if(vn(r),yn(r),r.some(e=>e.completionOrder>n))throw Error(`Session unread completion order exceeds catalog revision`);return{catalogId:bn(t,`catalogId`,512),catalogRevision:n,sessions:r}}function gn(e){let t=E(e);if(t.type!==`sessions.unread`)throw Error(`Invalid session unread event type`);let n=bn(t,`sessionId`,512),r=bn(t,`cwd`,Dt),i=xn(t,`catalogRevision`),a=t.unread===null?null:_n(t.unread);if(a!==null&&(a.sessionId!==n||a.cwd!==r))throw Error(`Session unread event identity mismatch`);if(a!==null&&a.completionOrder>i)throw Error(`Session unread completion order exceeds catalog revision`);return{type:`sessions.unread`,catalogId:bn(t,`catalogId`,512),catalogRevision:i,sessionId:n,cwd:r,unread:a}}function _n(e){let t=E(e),n=bn(t,`completedAt`,64),r=new Date(n);if(!Number.isFinite(r.getTime())||r.toISOString()!==n)throw Error(`Invalid canonical session unread completion time`);return{sessionId:bn(t,`sessionId`,512),cwd:bn(t,`cwd`,Dt),completionOrder:xn(t,`completionOrder`),completedAt:n}}function vn(e){let t=e.map(e=>JSON.stringify([e.sessionId,e.cwd]));if(new Set(t).size!==t.length)throw Error(`Duplicate session unread identity`);let n=e.map(e=>e.completionOrder);if(new Set(n).size!==n.length)throw Error(`Duplicate session unread completion order`)}function yn(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.completionOrder<=r.completionOrder)throw Error(`Session unread summaries are not newest-first`)}}function bn(e,t,n){let r=Nn(e,t);if(r.length>n)throw Error(`String field exceeds limit: ${t}`);return r}function xn(e,t){let n=Pn(e,t);if(n===0)throw Error(`Expected positive safe integer field: ${t}`);return n}function Sn(e){let t=E(e),n=wn(t.summary),r=jn(t.notifications,Tn,100,`notifications`);if(Fn(r),In(r),n.retainedCount!==r.length)throw Error(`Notification snapshot retained count mismatch`);if(n.highestSeverity!==Rn(r))throw Error(`Notification snapshot severity mismatch`);let i=En(t.dismissThrough),a=r[0]?.order??0;if(i.order!==a)throw Error(`Notification snapshot dismiss cutoff mismatch`);if(i.overflowWatermark<n.discardedCount)throw Error(`Notification snapshot overflow cutoff mismatch`);return{daemonInstanceId:Nn(t,`daemonInstanceId`),catalogRevision:Pn(t,`catalogRevision`),summary:n,notifications:r,dismissThrough:i}}function Cn(e){let t=E(e);if(t.type!==`notifications.inbox`)throw Error(`Invalid notification inbox event type`);let n=wn(t.summary),r=En(t.dismissThrough);if(r.overflowWatermark<n.discardedCount)throw Error(`Notification event overflow cutoff mismatch`);let i=Dn(t.delta);if(i.kind===`cleared`&&!Ln(n))throw Error(`Notification clear event summary mismatch`);if(i.kind===`added`&&n.retainedCount===0)throw Error(`Notification add event summary mismatch`);return{type:`notifications.inbox`,daemonInstanceId:Nn(t,`daemonInstanceId`),catalogRevision:Pn(t,`catalogRevision`),summary:n,dismissThrough:r,delta:i}}function wn(e){let t=E(e),n=Pn(t,`retainedCount`);if(n>100)throw Error(`Notification retained count exceeds limit`);let r=Pn(t,`discardedCount`),i=kn(t.highestSeverity);if(n===0!=(i===void 0))throw Error(`Notification summary severity mismatch`);return{sessionId:Nn(t,`sessionId`),cwd:Nn(t,`cwd`),inboxRevision:Pn(t,`inboxRevision`),retainedCount:n,discardedCount:r,...i===void 0?{}:{highestSeverity:i}}}function Tn(e){let t=E(e),n=D(t,`message`);if(new TextEncoder().encode(n).byteLength>8192)throw Error(`Notification message exceeds byte limit`);let r=D(t,`receivedAt`);if(!Number.isFinite(Date.parse(r)))throw Error(`Invalid notification receive time`);let i=Pn(t,`order`);if(i===0)throw Error(`Invalid notification order`);return{id:Nn(t,`id`),message:n,truncated:A(t,`truncated`),severity:On(t.severity),receivedAt:r,order:i}}function En(e){let t=E(e);return{order:Pn(t,`order`),overflowWatermark:Pn(t,`overflowWatermark`)}}function Dn(e){let t=E(e);switch(t.kind){case`added`:{let e=O(t,`evictedNotificationId`);return{kind:`added`,notification:Tn(t.notification),...e===void 0?{}:{evictedNotificationId:e}}}case`dismissed`:{let e=jn(t.notificationIds,Mn,100,`notificationIds`);if(new Set(e).size!==e.length)throw Error(`Duplicate dismissed notification id`);return{kind:`dismissed`,notificationIds:e}}case`cleared`:return{kind:`cleared`,reason:An(t.reason)};case`resync`:return{kind:`resync`};default:throw Error(`Invalid notification inbox delta`)}}function On(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid notification severity`);return e}function kn(e){return e===void 0?void 0:On(e)}function An(e){switch(e){case`runtime-close`:case`archive`:case`delete`:case`restore`:case`archive-reconcile`:case`replacement`:case`initialization-failed`:case`service-dispose`:return e;default:throw Error(`Invalid notification clear reason`)}}function jn(e,t,n,r){if(!Array.isArray(e))throw Error(`Expected array field: ${r}`);if(e.length>n)throw Error(`Array field exceeds limit: ${r}`);return e.map(t)}function Mn(e){if(typeof e!=`string`||e===``)throw Error(`Expected non-empty string`);return e}function Nn(e,t){let n=D(e,t);if(n===``)throw Error(`Expected non-empty string field: ${t}`);return n}function Pn(e,t){let n=e[t];if(typeof n!=`number`||!Number.isSafeInteger(n)||n<0)throw Error(`Expected non-negative safe integer field: ${t}`);return n}function Fn(e){if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate notification id`);if(new Set(e.map(e=>e.order)).size!==e.length)throw Error(`Duplicate notification order`)}function In(e){for(let t=1;t<e.length;t+=1){let n=e[t-1],r=e[t];if(n===void 0||r===void 0||n.order<=r.order)throw Error(`Notifications are not newest-first`)}}function Ln(e){return e.retainedCount===0&&e.discardedCount===0}function Rn(e){let t;for(let n of e){if(n.severity===`error`)return`error`;n.severity===`warning`?t=`warning`:t??=`info`}return t}function zn(e){let t=E(e),n=t.skippedBusySessionIds===void 0?void 0:Yt(t.skippedBusySessionIds,`skippedBusySessionIds`);return{generatedAt:D(t,`generatedAt`),thresholds:Wn(t.thresholds),projects:j(Gn)(t.projects),totals:Kn(t.totals),...n===void 0?{}:{skippedBusySessionIds:n}}}function Bn(e){let t=E(e);return{...zn(t),archivedSessionIds:Yt(t.archivedSessionIds,`archivedSessionIds`),deletedSessionIds:Yt(t.deletedSessionIds,`deletedSessionIds`)}}function Vn(e){let t=E(e);if(t.archived!==!0)throw Error(`Expected bulk archived response`);return{archived:!0,archivedSessionIds:Yt(t.archivedSessionIds,`archivedSessionIds`),failures:j(Un)(t.failures),generatedAt:D(t,`generatedAt`)}}function Hn(e){let t=E(e);if(t.deleted!==!0)throw Error(`Expected bulk deleted response`);return{deleted:!0,deletedSessionIds:Yt(t.deletedSessionIds,`deletedSessionIds`),failures:j(Un)(t.failures),generatedAt:D(t,`generatedAt`)}}function Un(e){let t=E(e);return{sessionId:D(t,`sessionId`),error:D(t,`error`)}}function Wn(e){let t=E(e);return{...N(`archiveIdleDays`,M(t,`archiveIdleDays`)),...N(`deleteArchivedDays`,M(t,`deleteArchivedDays`))}}function Gn(e){let t=E(e);return{cwd:D(t,`cwd`),archiveCount:k(t,`archiveCount`),deleteCount:k(t,`deleteCount`)}}function Kn(e){let t=E(e);return{archiveCount:k(t,`archiveCount`),deleteCount:k(t,`deleteCount`)}}function qn(e){let t=E(e),n=D(t,`kind`);if(n!==`steer`&&n!==`followUp`)throw Error(`Invalid queued message kind`);return{kind:n,text:D(t,`text`)}}function Jn(e){let t=E(e);return{input:k(t,`input`),output:k(t,`output`),cacheRead:k(t,`cacheRead`),cacheWrite:k(t,`cacheWrite`),total:k(t,`total`)}}function Yn(e){let t=E(e);return{...N(`provider`,O(t,`provider`)),...N(`id`,O(t,`id`)),...N(`name`,O(t,`name`)),...N(`contextWindow`,M(t,`contextWindow`)),...N(`reasoning`,t.reasoning)}}function Xn(e){return e===void 0?{}:{model:Yn(e)}}function Zn(e){let t=E(e);return{models:j(Yn)(t.models)}}function Qn(e){let t=E(e);return{...t.model===void 0?{}:{model:Yn(t.model)},thinkingLevel:D(t,`thinkingLevel`),models:j(Yn)(t.models),thinkingLevels:Yt(t.thinkingLevels,`thinkingLevels`)}}function $n(e){let t=nr(e,`models configuration`),n=t.providers;if(n===void 0)return{...t,providers:{}};let r=nr(n,`models configuration providers`),i={};for(let[e,t]of Object.entries(r))i[e]=er(t);return{...t,providers:i}}function er(e){let t=nr(e,`models configuration provider`),n={};for(let[e,r]of Object.entries(t))n[e]=r;let r=O(t,`baseUrl`);r!==void 0&&(n.baseUrl=r);let i=O(t,`api`);i!==void 0&&(n.api=i);let a=O(t,`apiKey`);a!==void 0&&(n.apiKey=a);let o=rr(t.headers,`models configuration provider headers`);o!==void 0&&(n.headers=ir(o,`models configuration provider headers`));let s=rr(t.compat,`models configuration provider compatibility`);s!==void 0&&(n.compat={...s});let c=rr(t.modelOverrides,`models configuration provider model overrides`);c!==void 0&&(n.modelOverrides={...c});let l=t.models;if(l!==void 0){if(!Array.isArray(l))throw Error(`Expected models configuration models array`);n.models=l.map(tr)}return n}function tr(e){let t=nr(e,`models configuration model`),n={id:D(t,`id`)};for(let[e,r]of Object.entries(t))n[e]=r;n.id=D(t,`id`);let r=O(t,`name`);r!==void 0&&(n.name=r);let i=O(t,`api`);i!==void 0&&(n.api=i);let a=_a(t,`reasoning`);a!==void 0&&(n.reasoning=a);let o=rr(t.thinkingLevelMap,`models configuration thinking level map`);o!==void 0&&(n.thinkingLevelMap=ar(o));let s=t.input;if(s!==void 0){if(!Array.isArray(s)||!s.every(e=>typeof e==`string`))throw Error(`Expected models configuration model input array of strings`);n.input=[...s]}let c=M(t,`contextWindow`);c!==void 0&&(n.contextWindow=c);let l=M(t,`maxTokens`);l!==void 0&&(n.maxTokens=l);let u=rr(t.cost,`models configuration model cost`);u!==void 0&&(n.cost=or(u));let d=rr(t.compat,`models configuration model compatibility`);return d!==void 0&&(n.compat={...d}),n}function nr(e,t){if(!qt(e)||Array.isArray(e))throw Error(`Expected ${t} object`);return e}function rr(e,t){if(e!==void 0)return nr(e,t)}function ir(e,t){let n={};for(let[r,i]of Object.entries(e)){if(typeof i!=`string`)throw Error(`Expected ${t} values to be strings`);n[r]=i}return n}function ar(e){let t={};for(let[n,r]of Object.entries(e)){if(r!==null&&typeof r!=`string`)throw Error(`Expected models configuration thinking level map values to be strings or null`);t[n]=r}return t}function or(e){let t={};for(let n of[`input`,`output`,`cacheRead`,`cacheWrite`]){let r=e[n];if(r!==void 0){if(typeof r!=`number`)throw Error(`Expected models configuration model cost ${n} to be a number`);t[n]=r}}return t}function sr(e){if(E(e).success!==!0)throw Error(`Expected successful models configuration save`);return{success:!0}}function cr(e){let t=E(e);return{models:j(lr)(t.models)}}function lr(e){let t=E(e),n=D(t,`id`),r=O(t,`name`);return r===void 0?{id:n}:{id:n,name:r}}function ur(e){let t=E(e),n=A(t,`ok`),r=O(t,`error`),i=t.latencyMs===void 0?void 0:k(t,`latencyMs`),a=t.status===void 0?void 0:k(t,`status`),o=O(t,`responseText`);return{ok:n,...r===void 0?{}:{error:r},...i===void 0?{}:{latencyMs:i},...a===void 0?{}:{status:a},...o===void 0?{}:{responseText:o}}}function dr(e){let t=E(e);return{skills:j(fr)(t.skills)}}function fr(e){let t=E(e),n=E(t.sourceInfo),r=O(n,`source`),i=O(n,`scope`);return{name:D(t,`name`),description:D(t,`description`),filePath:D(t,`filePath`),baseDir:D(t,`baseDir`),disableModelInvocation:A(t,`disableModelInvocation`),sourceInfo:{...r===void 0?{}:{source:r},...i===void 0?{}:{scope:i}},...t.install===void 0?{}:{install:pr(t.install)}}}function pr(e){let t=E(e),n=O(t,`sourceType`),r=O(t,`skillsShUrl`),i=O(t,`skillPath`),a=O(t,`ref`),o=O(t,`versionHash`);return{package:D(t,`package`),scope:mr(t.scope),source:D(t,`source`),...n===void 0?{}:{sourceType:n},...r===void 0?{}:{skillsShUrl:r},...i===void 0?{}:{skillPath:i},...a===void 0?{}:{ref:a},...o===void 0?{}:{versionHash:o},canCheckForUpdates:A(t,`canCheckForUpdates`)}}function mr(e){if(e!==`global`&&e!==`project`)throw Error(`Expected skill install scope`);return e}function hr(e){if(E(e).success!==!0)throw Error(`Expected successful Skills mutation`);return{success:!0}}function gr(e){let t=E(e);return{results:j(_r)(t.results)}}function _r(e){let t=E(e);return{package:D(t,`package`),installs:D(t,`installs`),url:D(t,`url`)}}function vr(e){let t=E(e);return{updates:j(yr)(t.updates)}}function yr(e){let t=E(e),n=O(t,`currentVersion`),r=O(t,`latestVersion`),i=O(t,`message`);return{package:D(t,`package`),scope:mr(t.scope),state:br(t.state),...n===void 0?{}:{currentVersion:n},...r===void 0?{}:{latestVersion:r},...i===void 0?{}:{message:i}}}function br(e){if(e!==`up-to-date`&&e!==`update-available`&&e!==`unsupported`&&e!==`error`)throw Error(`Expected skill update state`);return e}function xr(e){let t=E(e);if(t.success!==!0)throw Error(`Expected successful Skills update`);let n=O(t,`output`);return{success:!0,...t.skill===void 0?{}:{skill:fr(t.skill)},...n===void 0?{}:{output:n}}}function Sr(e){if(typeof e!=`string`)throw Error(`Invalid thinking level`);return e}function Cr(e){let t=E(e);return{levels:j(Sr)(t.levels)}}function wr(e){if(e!==`oauth`&&e!==`api_key`)throw Error(`Invalid auth type`);return e}function Tr(e){if(e!==`stored`&&e!==`runtime`&&e!==`environment`&&e!==`fallback`&&e!==`models_json_key`&&e!==`models_json_command`)throw Error(`Invalid auth status source`);return e}function Er(e){let t=E(e),n=t.source===void 0?void 0:Tr(t.source);return{configured:A(t,`configured`),...N(`source`,n),...N(`label`,O(t,`label`))}}function Dr(e){let t=E(e),n=t.loginFlow;if(n!==void 0&&n!==`interactive`)throw Error(`Invalid auth provider login flow`);return{id:D(t,`id`),name:D(t,`name`),authType:wr(t.authType),status:Er(t.status),...n===void 0?{}:{loginFlow:n}}}function Or(e){let t=E(e);return{providers:j(Dr)(t.providers)}}function kr(e){let t=E(e);return{flowId:D(t,`flowId`),providerId:D(t,`providerId`),providerName:D(t,`providerName`),status:Ar(t.status),progress:j(e=>{if(typeof e!=`string`)throw Error(`Expected progress item string`);return e})(t.progress),...N(`error`,O(t,`error`)),...N(`auth`,jr(t.auth)),...N(`prompt`,Nr(t.prompt)),...N(`select`,Fr(t.select)),...N(`info`,Ir(t.info))}}function Ar(e){if(e!==`running`&&e!==`complete`&&e!==`error`&&e!==`cancelled`)throw Error(`Invalid OAuth flow status`);return e}function jr(e){if(e===void 0)return;let t=E(e);return{url:D(t,`url`),...N(`instructions`,O(t,`instructions`)),...N(`deviceCode`,Mr(t.deviceCode))}}function Mr(e){if(e===void 0)return;let t=E(e);return{userCode:D(t,`userCode`),...N(`intervalSeconds`,M(t,`intervalSeconds`)),...N(`expiresInSeconds`,M(t,`expiresInSeconds`))}}function Nr(e){if(e===void 0)return;let t=E(e),n=D(t,`kind`);if(n!==`prompt`&&n!==`manual`)throw Error(`Invalid OAuth prompt kind`);let r=t.promptType===void 0?n===`manual`?`manual_code`:`text`:Pr(t.promptType);return{requestId:D(t,`requestId`),message:D(t,`message`),kind:n,promptType:r,...N(`placeholder`,O(t,`placeholder`)),...N(`allowEmpty`,_a(t,`allowEmpty`))}}function Pr(e){if(e!==`text`&&e!==`secret`&&e!==`manual_code`)throw Error(`Invalid OAuth prompt type`);return e}function Fr(e){if(e===void 0)return;let t=E(e);return{requestId:D(t,`requestId`),message:D(t,`message`),options:j(ia)(t.options)}}function Ir(e){if(e!==void 0)return j(e=>{let t=E(e);return{message:D(t,`message`),...N(`links`,t.links===void 0?void 0:j(Lr)(t.links))}})(e)}function Lr(e){let t=E(e);return{url:D(t,`url`),...N(`label`,O(t,`label`))}}function Rr(e){if(e===void 0)return{};let t=E(e);return{generation:{outputTokens:k(t,`outputTokens`),...N(`tokensPerSecond`,M(t,`tokensPerSecond`)),...N(`estimated`,_a(t,`estimated`))}}}function zr(e){if(e===void 0)return{};let t=E(e);return{contextUsage:{tokens:va(t,`tokens`),contextWindow:k(t,`contextWindow`),percent:va(t,`percent`)}}}function Br(e){let t=E(e),n=D(t,`source`);if(n!==`extension`&&n!==`prompt`&&n!==`skill`&&n!==`builtin`)throw Error(`Invalid command source`);return{name:D(t,`name`),source:n,...N(`description`,O(t,`description`))}}function Vr(e){let t=E(e),n=D(t,`kind`);if(n!==`tracked`&&n!==`untracked`&&n!==`other`)throw Error(`Invalid file kind`);return{path:D(t,`path`),kind:n}}function Hr(e){let t=E(e);return{path:D(t,`path`),entries:j(Ur)(t.entries),scannedAt:D(t,`scannedAt`),truncated:A(t,`truncated`)}}function Ur(e){let t=E(e),n=D(t,`type`);if(n!==`file`&&n!==`directory`&&n!==`symlink`)throw Error(`Invalid file tree entry type`);return{name:D(t,`name`),path:D(t,`path`),type:n,...N(`size`,M(t,`size`)),...N(`modifiedAt`,O(t,`modifiedAt`))}}function Wr(e){let t=E(e),n=D(t,`encoding`);if(n!==`utf8`)throw Error(`Invalid file encoding`);return{path:D(t,`path`),...N(`language`,O(t,`language`)),...N(`mediaType`,Jr(t.mediaType)),...N(`mimeType`,O(t,`mimeType`)),encoding:n,size:k(t,`size`),modifiedAt:D(t,`modifiedAt`),content:D(t,`content`),truncated:A(t,`truncated`),binary:A(t,`binary`)}}function Gr(e){let t=E(e);return{path:D(t,`path`),size:k(t,`size`),modifiedAt:D(t,`modifiedAt`),created:A(t,`created`)}}function Kr(e){let t=E(e);return{path:D(t,`path`),existed:A(t,`existed`)}}function qr(e){let t=E(e);return{fromPath:D(t,`fromPath`),toPath:D(t,`toPath`),size:k(t,`size`),modifiedAt:D(t,`modifiedAt`)}}function Jr(e){if(e!==void 0){if(e!==`image`)throw Error(`Invalid file media type`);return e}}function Yr(e){let t=E(e);return{isGitRepo:A(t,`isGitRepo`),hash:D(t,`hash`),...N(`branch`,O(t,`branch`)),...N(`latestTag`,O(t,`latestTag`)),...N(`upstream`,O(t,`upstream`)),...N(`ahead`,M(t,`ahead`)),...N(`behind`,M(t,`behind`)),files:j(Xr)(t.files)}}function Xr(e){let t=E(e);return{path:D(t,`path`),...N(`oldPath`,O(t,`oldPath`)),index:Zr(t.index),workingTree:Zr(t.workingTree)}}function Zr(e){switch(e){case`unmodified`:case`modified`:case`added`:case`deleted`:case`renamed`:case`copied`:case`untracked`:case`ignored`:case`conflicted`:return e;default:throw Error(`Invalid git file state`)}}function Qr(e){let t=E(e);return{...N(`path`,O(t,`path`)),staged:A(t,`staged`),hash:D(t,`hash`),diff:D(t,`diff`),truncated:A(t,`truncated`)}}function $r(e){let t=E(e);return{id:D(t,`id`),cwd:D(t,`cwd`),name:D(t,`name`),createdAt:D(t,`createdAt`),exited:A(t,`exited`),...N(`exitCode`,M(t,`exitCode`)),...N(`commandRunId`,O(t,`commandRunId`))}}function ei(e){let t=E(e);return{id:D(t,`id`),origin:D(t,`origin`),projectId:D(t,`projectId`),workspaceId:D(t,`workspaceId`),terminalId:D(t,`terminalId`),title:D(t,`title`),command:D(t,`command`),status:ti(t.status),...N(`exitCode`,M(t,`exitCode`)),createdAt:D(t,`createdAt`),...N(`startedAt`,O(t,`startedAt`)),...N(`completedAt`,O(t,`completedAt`)),metadata:ni(t.metadata,`metadata`)}}function ti(e){if(e!==`queued`&&e!==`running`&&e!==`succeeded`&&e!==`failed`)throw Error(`Invalid terminal command run status`);return e}function ni(e,t){let n=E(e);return Object.fromEntries(Object.entries(n).map(([e,n])=>{if(typeof n!=`string`)throw Error(`Expected string record field: ${t}.${e}`);return[e,n]}))}function ri(e){let t=E(e);return{cwd:D(t,`cwd`),hasSessionActivity:A(t,`hasSessionActivity`),hasTerminalActivity:A(t,`hasTerminalActivity`),updatedAt:D(t,`updatedAt`)}}function ii(e){let t=E(e);return{workspaces:j(ri)(t.workspaces),generatedAt:D(t,`generatedAt`)}}function ai(e){let t=E(e);return{path:D(t,`path`),exists:A(t,`exists`),config:oi(t.config),effectiveConfig:oi(t.effectiveConfig),envOverrides:gi(t.envOverrides)}}function oi(e){let t=E(e);return{...N(`host`,O(t,`host`)),...N(`port`,M(t,`port`)),...N(`allowedHosts`,ci(t.allowedHosts)),...N(`shortcuts`,mi(t.shortcuts)),...N(`plugins`,hi(t.plugins)),...N(`pathAccess`,li(t.pathAccess)),...N(`uploads`,di(t.uploads)),...N(`maxUploadBytes`,M(t,`maxUploadBytes`)),...N(`agent`,si(t.agent)),...N(`spawnSessions`,_a(t,`spawnSessions`)),...N(`subsessions`,_a(t,`subsessions`))}}function si(e){if(e!==void 0){if(!qt(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI agent field`);return{...N(`command`,O(e,`command`)),...N(`dir`,O(e,`dir`))}}}function ci(e){if(e!==void 0){if(e===!0)return!0;if(fi(e))return e;throw Error(`Invalid PI WEBUI allowedHosts field`)}}function li(e){if(e===void 0)return;if(!qt(e))throw Error(`Invalid PI WEBUI pathAccess field`);let t=e.allowedPaths;return{...N(`allowedPaths`,ui(t,`pathAccess.allowedPaths`))}}function ui(e,t){if(e!==void 0){if(pi(e))return e;throw Error(`Invalid PI WEBUI ${t} field`)}}function di(e){if(e!==void 0){if(!qt(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI uploads field`);return{...N(`defaultFolder`,O(e,`defaultFolder`))}}}function fi(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function pi(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`&&e!==``)}function mi(e){if(e!==void 0){if(!qt(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI shortcuts field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t!==null&&(typeof t!=`string`||t===``))throw Error(`Invalid PI WEBUI shortcut field`);return[e,t]}))}}function hi(e){if(e!==void 0){if(!qt(e)||Array.isArray(e))throw Error(`Invalid PI WEBUI plugins field`);return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!qt(t)||Array.isArray(t))throw Error(`Invalid PI WEBUI plugin config field`);let n=t.enabled;if(n!==void 0&&typeof n!=`boolean`)throw Error(`Invalid PI WEBUI plugin enabled field`);let r=t.settings;if(r!==void 0&&(!qt(r)||Array.isArray(r)))throw Error(`Invalid PI WEBUI plugin settings field`);return[e,t]}))}}function gi(e){let t=E(e);return{host:A(t,`host`),port:A(t,`port`),allowedHosts:A(t,`allowedHosts`),spawnSessions:A(t,`spawnSessions`),subsessions:A(t,`subsessions`),agentCommand:_a(t,`agentCommand`)??!1,agentDir:_a(t,`agentDir`)??!1,..._i(t),agentSessionDir:_a(t,`agentSessionDir`)??!1}}function _i(e){let t=e.agentDirSource;if(t===void 0)return{};if(t!==`pi-webui`&&t!==`pi-compatibility`)throw Error(`Invalid PI WEBUI agentDirSource field`);return{agentDirSource:t}}function vi(e){let t=E(e);return{packages:j(bi)(t.packages)}}function yi(e){let t=E(e),n=O(t,`source`),r=t.scope===void 0?void 0:xi(t.scope),i=Pi(t.removed,`removed`);return{action:Si(t.action),...N(`source`,n),...N(`scope`,r),...N(`removed`,i),packages:j(bi)(t.packages)}}function bi(e){let t=E(e);return{source:D(t,`source`),scope:xi(t.scope),filtered:A(t,`filtered`),...N(`installedPath`,O(t,`installedPath`))}}function xi(e){if(e!==`user`&&e!==`project`)throw Error(`Invalid Pi package scope`);return e}function Si(e){if(e!==`install`&&e!==`remove`&&e!==`update`)throw Error(`Invalid Pi package mutation action`);return e}function Ci(e){let t=E(e);return{packages:j(wi)(t.packages),totals:Di(t.totals),diagnostics:j(Ai)(t.diagnostics)}}function wi(e){let t=E(e);return{source:D(t,`source`),scope:Ti(t.scope),filtered:A(t,`filtered`),disabled:A(t,`disabled`),...N(`installedPath`,O(t,`installedPath`)),...N(`packageName`,O(t,`packageName`)),...N(`version`,O(t,`version`)),...N(`configuredVersion`,O(t,`configuredVersion`)),counts:Di(t.counts),resources:j(Oi)(t.resources),status:Ei(t.status)}}function Ti(e){if(e!==`global`&&e!==`project`)throw Error(`Invalid Pi package plugin scope`);return e}function Ei(e){if(e!==`loaded`&&e!==`installed`&&e!==`missing`&&e!==`disabled`)throw Error(`Invalid Pi package plugin status`);return e}function Di(e){let t=E(e);return{extensions:k(t,`extensions`),skills:k(t,`skills`),prompts:k(t,`prompts`),themes:k(t,`themes`)}}function Oi(e){let t=E(e);return{kind:ki(t.kind),name:D(t,`name`),path:D(t,`path`),relativePath:D(t,`relativePath`)}}function ki(e){if(e!==`extension`&&e!==`skill`&&e!==`prompt`&&e!==`theme`)throw Error(`Invalid Pi package plugin resource kind`);return e}function Ai(e){let t=E(e),n=t.type;if(n!==`warning`&&n!==`error`)throw Error(`Invalid Pi package plugin diagnostic type`);return{type:n,message:D(t,`message`),...N(`source`,O(t,`source`)),...N(`path`,O(t,`path`))}}function ji(e){let t=E(e);return{plugins:j(Mi)(t.plugins)}}function Mi(e){let t=E(e);return{id:D(t,`id`),module:D(t,`module`),source:D(t,`source`),scope:Ni(t.scope),machineSpecific:Pi(t.machineSpecific,`machineSpecific`)??!1,enabled:A(t,`enabled`)}}function Ni(e){if(e!==`bundled`&&e!==`local`&&e!==`user`&&e!==`project`)throw Error(`Invalid PI WEBUI plugin scope`);return e}function Pi(e,t){if(e!==void 0){if(typeof e!=`boolean`)throw Error(`Expected optional boolean field: ${t}`);return e}}function Fi(e){let t=E(e);return{packageName:D(t,`packageName`),generatedAt:D(t,`generatedAt`),components:Li(t.components),release:Hi(t.release),commands:Ui(t.commands),messages:j(Wi)(t.messages)}}function Ii(e){let t=E(e);return{packageName:D(t,`packageName`),generatedAt:D(t,`generatedAt`),components:Ri(t.components),capabilities:Ki(t.capabilities)}}function Li(e){let t=E(e);return{web:Bi(t.web),sessiond:Bi(t.sessiond)}}function Ri(e){let t=E(e);return{web:zi(t.web),sessiond:zi(t.sessiond)}}function zi(e){let t=E(e),n=Gi(t.component),r=t.activeAgentProfile,i=r===void 0?void 0:It(r);if(r!==void 0&&(n!==`sessiond`||i===void 0))throw Error(`Invalid active agent profile descriptor`);return{component:n,label:D(t,`label`),...N(`runtimeVersion`,O(t,`runtimeVersion`)),available:A(t,`available`),capabilities:Ki(t.capabilities),...N(`activeAgentProfile`,i),...N(`error`,O(t,`error`))}}function Bi(e){let t=E(e);return{component:Gi(t.component),label:D(t,`label`),...N(`runtimeVersion`,O(t,`runtimeVersion`)),...N(`installedVersion`,O(t,`installedVersion`)),stale:A(t,`stale`),available:A(t,`available`),...N(`installation`,Vi(t.installation)),...N(`error`,O(t,`error`))}}function Vi(e){if(e===void 0)return;let t=E(e),n=D(t,`kind`);if(n!==`pi-package`&&n!==`npm-global`&&n!==`local`&&n!==`docker`&&n!==`unknown`)throw Error(`Invalid PI WEBUI installation kind`);let r=t.scope;if(r!==void 0&&r!==`user`&&r!==`project`)throw Error(`Invalid PI WEBUI installation scope`);let i=t.dockerMode;if(i!==void 0&&i!==`runtime`&&i!==`dev`)throw Error(`Invalid PI WEBUI Docker mode`);return{kind:n,...N(`path`,O(t,`path`)),...N(`source`,O(t,`source`)),...r===void 0?{}:{scope:r},...N(`npmRoot`,O(t,`npmRoot`)),...i===void 0?{}:{dockerMode:i}}}function Hi(e){let t=E(e);return{packageName:D(t,`packageName`),...N(`latestVersion`,O(t,`latestVersion`)),updateAvailable:A(t,`updateAvailable`),...N(`checkedAt`,O(t,`checkedAt`)),...t.skipped===!0?{skipped:!0}:{},...N(`error`,O(t,`error`))}}function Ui(e){let t=E(e);return{...N(`update`,O(t,`update`)),...N(`restart`,O(t,`restart`)),...N(`restartWeb`,O(t,`restartWeb`)),...N(`restartSessiond`,O(t,`restartSessiond`)),...N(`status`,O(t,`status`))}}function Wi(e){let t=E(e);return{id:D(t,`id`),severity:qi(t.severity),title:D(t,`title`),body:D(t,`body`),...N(`command`,O(t,`command`))}}function Gi(e){if(e!==`web`&&e!==`sessiond`)throw Error(`Invalid PI WEBUI service component`);return e}function Ki(e){let t=Kt(e);if(t===void 0)throw Error(`Invalid PI WEBUI capabilities`);return t}function qi(e){if(e!==`info`&&e!==`warning`&&e!==`error`)throw Error(`Invalid PI WEBUI status severity`);return e}function Ji(e){let t=E(e),n=D(t,`type`);if(n===`unsupported`)return{type:n,message:D(t,`message`)};if(n===`select`)return{type:n,requestId:D(t,`requestId`),title:D(t,`title`),options:j(ia)(t.options)};if(n===`tree`)return{type:n,tree:Yi(t.tree)};if(n===`done`)return{type:n,...N(`message`,O(t,`message`)),...aa(t.session),...N(`promptDraft`,O(t,`promptDraft`))};throw Error(`Invalid command result type`)}function Yi(e){let t=E(e),n=j(Xi)(t.nodes),r=new Set(n.map(e=>e.id));if(r.size!==n.length)throw Error(`Duplicate session tree node id`);let i=ta(t,`activeLeafId`);if(i!==null&&!r.has(i))throw Error(`Invalid session tree activeLeafId`);return{nodes:n,activeLeafId:i,activePathIds:ra(t.activePathIds,`activePathIds`)}}function Xi(e){let t=E(e);return{id:na(t,`id`),parentId:ta(t,`parentId`),kind:Zi(t.kind),summary:D(t,`summary`),...N(`timestamp`,O(t,`timestamp`)),...N(`label`,O(t,`label`))}}function Zi(e){switch(e){case`user`:case`assistant`:case`tool-result`:case`bash`:case`custom-message`:case`compaction`:case`branch-summary`:case`model-change`:case`thinking-level-change`:case`session-info`:case`label`:case`custom`:case`other`:return e;default:throw Error(`Invalid session tree node kind`)}}function Qi(e){let t=E(e),n=A(t,`cancelled`);if(Object.hasOwn(t,`summaryEntry`))throw Error(`Invalid session tree navigation result field: summaryEntry`);if(n){ea(t,`editorText`,`session tree cancellation result`);let e=t.aborted;if(e!==void 0&&typeof e!=`boolean`)throw Error(`Expected optional boolean field: aborted`);return{cancelled:n,...e===void 0?{}:{aborted:e}}}return ea(t,`aborted`,`session tree navigation result`),{cancelled:n,...N(`editorText`,O(t,`editorText`))}}function $i(e){let t=E(e);return A(t,`cancelled`)?(ea(t,`session`,`session fork cancellation result`),{cancelled:!0}):{cancelled:!1,session:sn(t.session)}}function ea(e,t,n){if(Object.hasOwn(e,t))throw Error(`Invalid ${n} field: ${t}`)}function ta(e,t){let n=e[t];if(n!==null&&typeof n!=`string`)throw Error(`Expected string or null field: ${t}`);if(typeof n==`string`&&n.trim()===``)throw Error(`Expected non-blank string or null field: ${t}`);return n}function na(e,t){let n=D(e,t);if(n.trim()===``)throw Error(`Expected non-blank string field: ${t}`);return n}function ra(e,t){let n=Yt(e,t);if(n.some(e=>e.trim()===``))throw Error(`Expected non-blank string array field: ${t}`);return n}function ia(e){let t=E(e);return{value:D(t,`value`),label:D(t,`label`),...N(`description`,O(t,`description`))}}function aa(e){return e===void 0?{}:{session:sn(e)}}function oa(e){if(E(e).accepted!==!0)throw Error(`Expected accepted response`);return{accepted:!0}}function sa(e){let t=E(e);return j(ca)(t.attachments)}function ca(e){let t=E(e);return{path:D(t,`path`),mimeType:D(t,`mimeType`),size:k(t,`size`)}}function la(e){if(E(e).closed!==!0)throw Error(`Expected closed response`);return{closed:!0}}function ua(e){if(E(e).aborted!==!0)throw Error(`Expected aborted response`);return{aborted:!0}}function da(e){if(E(e).stopped!==!0)throw Error(`Expected stopped response`);return{stopped:!0}}function fa(e){let t=E(e);if(t.archived!==!0)throw Error(`Expected archived response`);let n=t.sessionIds===void 0?void 0:Yt(t.sessionIds,`sessionIds`),r=M(t,`archivedCount`),i=M(t,`skippedAlreadyArchivedCount`);return{archived:!0,...n===void 0?{}:{sessionIds:n},...r===void 0?{}:{archivedCount:r},...i===void 0?{}:{skippedAlreadyArchivedCount:i}}}function pa(e){if(E(e).restored!==!0)throw Error(`Expected restored response`);return{restored:!0}}function ma(e){if(E(e).deleted!==!0)throw Error(`Expected deleted response`);return{deleted:!0}}function ha(e){if(E(e).detached!==!0)throw Error(`Expected detached response`);return{detached:!0}}function ga(e){if(E(e).reloaded!==!0)throw Error(`Expected reloaded response`);return{reloaded:!0}}function _a(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`boolean`)throw Error(`Invalid PI WEBUI ${t} field`);return n}}function M(e,t){let n=e[t];if(n!==void 0){if(typeof n!=`number`)throw Error(`Expected optional number field: ${t}`);return n}}function va(e,t){let n=e[t];if(n===null)return null;if(typeof n!=`number`)throw Error(`Expected number|null field: ${t}`);return n}function N(e,t){return t===void 0?{}:{[e]:t}}function ya(e){let t=E(e),n=E(t.memory),r=E(t.network);return{generatedAt:D(t,`generatedAt`),memory:{totalBytes:k(n,`totalBytes`),usedBytes:k(n,`usedBytes`),freeBytes:k(n,`freeBytes`),usagePercent:k(n,`usagePercent`)},network:Sa(r)}}function ba(e){let t=E(e),n=E(t.os),r=E(t.cpu),i=E(t.memory),a=E(t.network),o=t.gpu,s;if(o!=null){let e=E(o),t={name:D(e,`name`)},n=O(e,`driverVersion`);n!==void 0&&(t.driverVersion=n);let r=M(e,`memoryTotalBytes`);r!==void 0&&(t.memoryTotalBytes=r);let i=M(e,`memoryUsedBytes`);i!==void 0&&(t.memoryUsedBytes=i);let a=M(e,`utilizationPercent`);a!==void 0&&(t.utilizationPercent=a);let c=M(e,`temperatureCelsius`);c!==void 0&&(t.temperatureCelsius=c),s=t}let c={generatedAt:D(t,`generatedAt`),os:{platform:D(n,`platform`),release:D(n,`release`),arch:D(n,`arch`),uptimeSeconds:k(n,`uptimeSeconds`)},cpu:{model:D(r,`model`),cores:k(r,`cores`),usagePercent:k(r,`usagePercent`)},memory:{totalBytes:k(i,`totalBytes`),usedBytes:k(i,`usedBytes`),freeBytes:k(i,`freeBytes`),usagePercent:k(i,`usagePercent`)},network:xa(a)};s!==void 0&&(c.gpu=s);let l=O(t,`piVersion`);l!==void 0&&(c.piVersion=l);let u=O(t,`piWebUiVersion`);return u!==void 0&&(c.piWebUiVersion=u),c}function xa(e){let t={hostname:D(e,`hostname`),localIpv4Addresses:Yt(e.localIpv4Addresses,`localIpv4Addresses`),...Sa(e)},n=O(e,`publicIpv4`);n!==void 0&&(t.publicIpv4=n);let r=O(e,`publicIpv6`);return r!==void 0&&(t.publicIpv6=r),t}function Sa(e){let t={},n=M(e,`downloadSpeedBytesPerSecond`);n!==void 0&&(t.downloadSpeedBytesPerSecond=n);let r=M(e,`uploadSpeedBytesPerSecond`);return r!==void 0&&(t.uploadSpeedBytesPerSecond=r),t}function Ca(e){return typeof e==`string`?e:e.id}function wa(e){return typeof e==`string`?void 0:e.cwd}function Ta(e,t,n,r){let i=new URLSearchParams;r?.path!==void 0&&i.set(`path`,r.path),r?.staged===!0&&i.set(`staged`,`true`);let a=i.toString();return`api/machines/${encodeURIComponent(e)}/projects/${encodeURIComponent(t)}/workspaces/${encodeURIComponent(n)}/git/diff${a?`?${a}`:``}`}function Ea(e,t,n=`local`){let r=new URLSearchParams,i=wa(e);i!==void 0&&i!==``&&r.set(`cwd`,i),t?.limit!==void 0&&r.set(`limit`,String(t.limit)),t?.before!==void 0&&r.set(`before`,String(t.before));let a=r.toString();return`api/machines/${encodeURIComponent(n)}/sessions/${encodeURIComponent(Ca(e))}/messages${a===``?``:`?${a}`}`}function Da(e,t=`local`){let n=new URLSearchParams,r=wa(e);r!==void 0&&r!==``&&n.set(`cwd`,r);let i=n.toString();return`api/machines/${encodeURIComponent(t)}/sessions/${encodeURIComponent(Ca(e))}/export${i===``?``:`?${i}`}`}function Oa(e,t,n,r){let i=new URLSearchParams({path:n});return r?.createDirs===!1&&i.set(`createDirs`,`false`),r?.overwrite===!1&&i.set(`overwrite`,`false`),bt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`)}function ka(e,t,n,r){let i=new URLSearchParams;return i.set(`path`,n),r?.modifiedAt!==void 0&&i.set(`v`,r.modifiedAt),bt(`${`api/machines/${encodeURIComponent(r?.machineId??`local`)}`}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${i.toString()}`)}var P=(e=`local`)=>`api/machines/${encodeURIComponent(e)}`;function Aa(e){return typeof e==`string`?e:e.id}function ja(e){return typeof e==`string`?void 0:e.cwd}function Ma(e,t=`local`){return`${P(t)}/sessions/${encodeURIComponent(Aa(e))}`}function F(e,t,n=`local`){return`${Ma(e,n)}/${t}`}function Na(e,t,n=`local`){return`${F(e,t,n)}${Fa(e)}`}function Pa(e,t=`local`){return`${Ma(e,t)}${Fa(e)}`}function Fa(e){let t=ja(e);return t===void 0||t===``?``:`?${new URLSearchParams({cwd:t}).toString()}`}function I(e,t={}){let n=ja(e);return JSON.stringify(n===void 0||n===``?t:{cwd:n,...t})}function Ia(e){return JSON.stringify({sessions:e.map(La)})}function La(e){let t=Aa(e),n=ja(e);return n===void 0||n===``?{id:t}:{id:t,cwd:n}}function Ra(e){return e===`local`?`api/pi-webui/status`:`${P(e)}/pi-webui/status`}var za={piWebUiStatus:(e=`local`)=>w(Ra(e),Fi),checkForUpdates:(e=`local`)=>w(`${Ra(e)}?refresh=1`,Fi,{cache:`no-store`}),piWebUiRuntime:()=>w(`api/pi-webui/runtime`,Ii),systemInfo:(e=`local`)=>w(`${P(e)}/pi-webui/system-info`,ba),systemMetrics:(e=`local`)=>w(`${P(e)}/pi-webui/system-metrics`,ya,{cache:`no-store`})},Ba={machines:()=>w(`api/machines`,Zt),addMachine:e=>w(`api/machines`,Qt,{method:`POST`,body:JSON.stringify(e)}),deleteMachine:e=>w(`api/machines/${encodeURIComponent(e)}`,e=>e,{method:`DELETE`}),health:e=>w(`api/machines/${encodeURIComponent(e)}/health`,$t),runtime:(e,t=!1)=>w(`api/machines/${encodeURIComponent(e)}/runtime${t?`?refresh=1`:``}`,en,t?{cache:`no-store`}:{})};function Va(e){return e===void 0?`api/config`:`${P(e)}/config`}function Ha(e){return e===void 0?`api/plugins`:`${P(e)}/plugins`}var Ua={config:e=>w(Va(e),ai),saveConfig:(e,t)=>w(Va(t),ai,{method:`PUT`,body:JSON.stringify({config:e})})},Wa={plugins:e=>w(Ha(e),ji)};function Ga(e=`local`){return`${P(e)}/models-config`}var Ka={config:(e=`local`)=>w(Ga(e),$n),save:(e,t=`local`)=>w(Ga(t),sr,{method:`PUT`,body:JSON.stringify(e)}),test:(e,t=`local`)=>w(`${Ga(t)}/test`,ur,{method:`POST`,body:JSON.stringify(e)}),discover:(e,t=`local`)=>w(`${Ga(t)}/discover`,cr,{method:`POST`,body:JSON.stringify(e)})};function qa(e=`local`){return`${P(e)}/skills`}function Ja(e,t=`local`){return`${qa(t)}?${new URLSearchParams({cwd:e}).toString()}`}var Ya={list:(e,t=`local`)=>w(Ja(e,t),dr),toggle:(e,t=`local`)=>w(qa(t),hr,{method:`PATCH`,body:JSON.stringify(e)}),search:(e,t=`local`)=>w(`${qa(t)}/search`,gr,{method:`POST`,body:JSON.stringify(e)}),install:(e,t=`local`)=>w(`${qa(t)}/install`,hr,{method:`POST`,body:JSON.stringify(e)}),check:(e,t=`local`)=>w(`${qa(t)}/check`,vr,{method:`POST`,body:JSON.stringify(e)}),update:(e,t=`local`)=>w(`${qa(t)}/update`,xr,{method:`POST`,body:JSON.stringify(e)})};function Xa(e=``,t){let n=t===void 0?`api/pi-packages`:`${P(t)}/pi-packages`;return e===``?n:`${n}/${e}`}var Za={packages:e=>w(Xa(``,e),vi),install:(e,t)=>{let n={source:e};return w(Xa(`install`,t),yi,{method:`POST`,body:JSON.stringify(n)})},remove:(e,t,n)=>{let r=t===void 0?{source:e}:{source:e,scope:t};return w(Xa(`remove`,n),yi,{method:`POST`,body:JSON.stringify(r)})},update:(e,t)=>{let n=e===void 0?void 0:{source:e};return w(Xa(`update`,t),yi,{method:`POST`,...n===void 0?{}:{body:JSON.stringify(n)}})}};function Qa(e=`local`){return`${P(e)}/package-plugins`}function $a(e,t=`local`){return`${Qa(t)}?${new URLSearchParams({cwd:e}).toString()}`}var eo={list:(e,t=`local`)=>w($a(e,t),Ci),mutate:(e,t=`local`)=>w(Qa(t),Ci,{method:`POST`,body:JSON.stringify(e)})},to={workspaceActivity:(e=`local`)=>w(`${P(e)}/activity`,ii)},no={projects:(e=`local`)=>w(`${P(e)}/projects`,j(rn)),addProject:(e,t,n,r=`local`)=>w(`${P(r)}/projects`,rn,{method:`POST`,body:JSON.stringify({path:e,name:t,create:n})}),closeProject:(e,t=`local`)=>w(`${P(t)}/projects/${encodeURIComponent(e)}`,la,{method:`DELETE`}),projectDirectories:(e,t=`local`)=>w(`${P(t)}/project-directories?q=${encodeURIComponent(e)}`,j(Vr))},ro={workspaces:(e,t=`local`)=>w(`${P(t)}/projects/${encodeURIComponent(e)}/workspaces`,j(an)),deleteWorkspace:(e,t,n=`local`)=>w(`${P(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}`,ei,{method:`DELETE`}),workspaceTree:(e,t,n=``,r=`local`)=>w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(n)}`,Hr),workspaceFile:(e,t,n,r=`local`)=>w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(n)}`,Wr),writeWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({path:n});i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!1&&o.set(`overwrite`,`false`);let s=r instanceof Uint8Array,c=s?new Uint8Array(r):new TextEncoder().encode(r);return w(`${P(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${o.toString()}`,Gr,{method:`PUT`,body:c,headers:{"Content-Type":s?`application/octet-stream`:`text/plain`}})},deleteWorkspaceFile:(e,t,n,r=`local`)=>{let i=new URLSearchParams({path:n});return w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?${i.toString()}`,Kr,{method:`DELETE`})},moveWorkspaceFile:(e,t,n,r,i,a=`local`)=>{let o=new URLSearchParams({fromPath:n,toPath:r});return i?.createDirs===!1&&o.set(`createDirs`,`false`),i?.overwrite===!0&&o.set(`overwrite`,`true`),w(`${P(a)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/move?${o.toString()}`,qr,{method:`POST`})}},io={sessions:(e,t=`local`)=>w(`${P(t)}/sessions?cwd=${encodeURIComponent(e)}`,j(sn)),unreadCatalog:(e=`local`)=>w(`${P(e)}/sessions/unread`,hn,{cache:`no-store`}),acknowledgeUnread:(e,t,n,r=`local`)=>{let i={cwd:e.cwd,catalogId:t,throughCompletionOrder:n};return w(F(e,`unread/acknowledge`,r),hn,{method:`POST`,body:JSON.stringify(i)})},notificationInbox:(e,t=`local`)=>w(Na(e,`notifications`,t),Sn),dismissNotification:(e,t,n,r=`local`)=>w(F(e,`notifications/dismiss`,r),Sn,{method:`POST`,body:I(e,{daemonInstanceId:t,notificationId:n})}),dismissAllNotifications:(e,t,n,r=`local`)=>w(F(e,`notifications/dismiss-all`,r),Sn,{method:`POST`,body:I(e,{daemonInstanceId:t,throughOrder:n.order,throughOverflowWatermark:n.overflowWatermark})}),startSession:(e,t=`local`)=>w(`${P(t)}/sessions`,sn,{method:`POST`,body:JSON.stringify({cwd:e})}),sessionDefaults:(e,t=`local`)=>w(`${P(t)}/session-defaults?cwd=${encodeURIComponent(e)}`,Qn),updateSessionDefaults:(e,t,n=`local`)=>w(`${P(n)}/session-defaults`,Qn,{method:`PUT`,body:JSON.stringify({cwd:e,...t})}),cleanupPreview:(e,t=`local`)=>w(`${P(t)}/sessions/cleanup/preview`,zn,{method:`POST`,body:JSON.stringify(e)}),cleanup:(e,t=`local`)=>w(`${P(t)}/sessions/cleanup`,Bn,{method:`POST`,body:JSON.stringify(e)}),forceCleanup:(e=`local`)=>w(`${P(e)}/sessions/cleanup/force`,Bn,{method:`POST`}),archiveMany:(e,t=`local`)=>w(`${P(t)}/sessions/bulk/archive`,Vn,{method:`POST`,body:Ia(e)}),deleteArchivedMany:(e,t=`local`)=>w(`${P(t)}/sessions/bulk/delete-archived`,Hn,{method:`POST`,body:Ia(e)}),messages:(e,t,n=`local`)=>w(Ea(e,t,n),Xt),status:(e,t=`local`)=>w(Na(e,`status`,t),fn),systemPrompt:(e,t=`local`)=>w(Na(e,`system-prompt`,t),mn),streamSnapshot:(e,t=`local`)=>w(Na(e,`stream-snapshot`,t),pn),clearQueue:(e,t=`local`)=>w(F(e,`queue/clear`,t),fn,{method:`POST`,body:I(e)}),dismissWarning:(e,t,n=`local`)=>w(F(e,`warnings/dismiss`,n),fn,{method:`POST`,body:I(e,{dismissId:t})}),models:(e,t=`local`)=>w(Na(e,`models`,t),Zn),setModel:(e,t,n,r=`local`)=>w(F(e,`model`,r),fn,{method:`POST`,body:I(e,{provider:t,modelId:n})}),cycleModel:(e,t,n=`local`)=>w(F(e,`model/cycle`,n),fn,{method:`POST`,body:I(e,{direction:t})}),thinkingLevels:(e,t=`local`)=>w(Na(e,`thinking-levels`,t),Cr),setThinkingLevel:(e,t,n=`local`)=>w(F(e,`thinking-level`,n),fn,{method:`POST`,body:I(e,{level:t})}),cycleThinkingLevel:(e,t=`local`)=>w(F(e,`thinking-level/cycle`,t),fn,{method:`POST`,body:I(e)}),commands:(e,t=`local`)=>w(Na(e,`commands`,t),j(Br)),prompt:(e,t,n,r=`local`,i)=>w(F(e,`prompt`,r),oa,{method:`POST`,body:I(e,{text:t,...n===void 0?{}:{streamingBehavior:n},...i!==void 0&&i.length>0?{attachments:i}:{}})}),saveAttachments:(e,t,n=`local`,r)=>w(F(e,`attachments`,n),sa,{method:`POST`,body:I(e,{attachments:t,...r===void 0?{}:{folder:r}})}),shell:(e,t,n=`local`)=>w(F(e,`shell`,n),oa,{method:`POST`,body:I(e,{text:t})}),runCommand:(e,t,n=`local`)=>w(F(e,`commands/run`,n),Ji,{method:`POST`,body:I(e,{text:t})}),respondToCommand:(e,t,n,r=`local`)=>w(F(e,`commands/respond`,r),Ji,{method:`POST`,body:I(e,{requestId:t,value:n})}),navigateTree:(e,t,n=`local`)=>w(F(e,`tree/navigate`,n),Qi,{method:`POST`,body:I(e,{targetId:t.targetId,expectedLeafId:t.expectedLeafId,summary:t.summary})}),editFromHere:(e,t,n=`local`)=>w(F(e,`messages/edit-from-here`,n),Qi,{method:`POST`,body:I(e,{entryId:t})}),forkFromHere:(e,t,n=`local`)=>w(F(e,`messages/fork`,n),$i,{method:`POST`,body:I(e,{entryId:t})}),abort:(e,t=`local`)=>w(F(e,`abort`,t),ua,{method:`POST`,body:I(e)}),stop:(e,t=`local`)=>w(F(e,`stop`,t),da,{method:`POST`,body:I(e)}),archive:(e,t=`local`)=>w(F(e,`archive`,t),fa,{method:`POST`,body:I(e)}),archiveWithDescendants:(e,t=`local`)=>w(F(e,`archive-tree`,t),fa,{method:`POST`,body:I(e)}),restore:(e,t=`local`)=>w(F(e,`restore`,t),pa,{method:`POST`,body:I(e)}),deleteArchived:(e,t=`local`)=>w(Pa(e,t),ma,{method:`DELETE`}),detachParent:(e,t=`local`)=>w(F(e,`detach-parent`,t),ha,{method:`POST`,body:I(e)}),reloadSession:(e,t=`local`)=>w(F(e,`reload`,t),ga,{method:`POST`,body:I(e)}),pin:(e,t=`local`)=>w(F(e,`pin`,t),sn,{method:`POST`,body:I(e)}),unpin:(e,t=`local`)=>w(F(e,`unpin`,t),sn,{method:`POST`,body:I(e)}),authProviders:e=>{let t=new URLSearchParams;e?.mode!==void 0&&t.set(`mode`,e.mode),e?.authType!==void 0&&t.set(`authType`,e.authType);let n=t.toString();return w(`${P(e?.machineId)}/auth/providers${n===``?``:`?${n}`}`,Or)},saveApiKey:(e,t,n=`local`)=>w(`${P(n)}/auth/api-key`,oa,{method:`POST`,body:JSON.stringify({providerId:e,key:t})}),startInteractiveApiKeyLogin:(e,t=`local`)=>w(`${P(t)}/auth/api-key/interactive`,kr,{method:`POST`,body:JSON.stringify({providerId:e})}),logoutProvider:(e,t=`local`)=>w(`${P(t)}/auth/logout`,oa,{method:`POST`,body:JSON.stringify({providerId:e})}),startOAuthLogin:(e,t=`local`)=>w(`${P(t)}/auth/oauth`,kr,{method:`POST`,body:JSON.stringify({providerId:e})}),oauthFlow:(e,t=`local`)=>w(`${P(t)}/auth/oauth/${encodeURIComponent(e)}`,kr),respondOAuthFlow:(e,t,n,r=`local`)=>w(`${P(r)}/auth/oauth/${encodeURIComponent(e)}/respond`,kr,{method:`POST`,body:JSON.stringify({requestId:t,value:n})}),cancelOAuthFlow:(e,t=`local`)=>w(`${P(t)}/auth/oauth/${encodeURIComponent(e)}/cancel`,kr,{method:`POST`})},ao={terminals:(e,t,n=`local`)=>w(`${P(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,j($r)),startTerminal:(e,t,n,r=`local`)=>w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,$r,{method:`POST`,body:JSON.stringify(n??{})}),closeWorkspaceTerminals:(e,t,n=`local`)=>w(`${P(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,la,{method:`DELETE`}),closeTerminal:(e,t,n,r=`local`)=>w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}`,la,{method:`DELETE`}),continueTerminal:(e,t,n,r=`local`)=>w(`${P(r)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/continue`,$r,{method:`POST`}),runTerminalCommand:(e,t,n=`local`)=>w(`${P(n)}/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,ei,{method:`POST`,body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:(e,t=`local`)=>w(`${P(t)}/terminal-command-runs${so(e)}`,j(ei)),getCommandRun:(e,t=`local`)=>oo(e,t),cancelCommandRun:(e,t=`local`)=>w(`${P(t)}/terminal-command-runs/${encodeURIComponent(e)}/cancel`,ei,{method:`POST`})};async function oo(e,t){let n=await fetch(bt(`${P(t)}/terminal-command-runs/${encodeURIComponent(e)}`));if(n.status!==404){if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(co(e)??n.statusText)}return ei(await n.json())}}function so(e){if(e===void 0)return``;let t=new URLSearchParams;e.projectId!==void 0&&t.set(`projectId`,e.projectId),e.workspaceId!==void 0&&t.set(`workspaceId`,e.workspaceId),e.terminalId!==void 0&&t.set(`terminalId`,e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set(`statuses`,e.statuses.join(`,`)),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set(`metadata`,JSON.stringify(e.metadata));let n=t.toString();return n===``?``:`?${n}`}function co(e){if(!lo(e))return;let t=e.error;return typeof t==`string`?t:void 0}function lo(e){return typeof e==`object`&&!!e}var uo={files:(e,t,n={})=>{let r=new URLSearchParams({q:t});return n.kind!==void 0&&r.set(`kind`,n.kind),n.mode!==void 0&&r.set(`mode`,n.mode),n.scope!==void 0&&r.set(`scope`,n.scope),n.workspaceScoped===!0&&n.projectId!==void 0&&n.workspaceId!==void 0?w(`${P(n.machineId)}/projects/${encodeURIComponent(n.projectId)}/workspaces/${encodeURIComponent(n.workspaceId)}/files?${r.toString()}`,j(Vr)):(r.set(`cwd`,e),w(`${P(n.machineId)}/files?${r.toString()}`,j(Vr)))}},fo={gitStatus:(e,t,n=`local`)=>w(`${P(n)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,Yr),gitDiff:(e,t,n,r=`local`)=>w(Ta(r,e,t,n),Qr)},L={...za,...Ba,...Ua,...Wa,...Za,...eo,...to,...no,...ro,...io,...ao,...uo,...fo};function po(e,t=`local`){let n=typeof e==`string`?void 0:e.cwd,r=n===void 0||n===``?``:`?${new URLSearchParams({cwd:n}).toString()}`,i=typeof e==`string`?e:e.id;return new WebSocket(xt(`${go(t)}/sessions/${encodeURIComponent(i)}/events${r}`))}function mo(e,t,n,r,i=`local`){let a=r===void 0?``:`?${new URLSearchParams({cols:String(r.cols),rows:String(r.rows)}).toString()}`;return new WebSocket(xt(`${go(i)}/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(n)}/socket${a}`))}function ho(e=`local`){return new WebSocket(xt(`${go(e)}/events`))}function go(e){return`api/machines/${encodeURIComponent(e)}`}var _o=`.pi-webui/uploads`,vo=class extends Error{constructor(e=`Workspace upload cancelled`){super(e),this.name=`WorkspaceUploadCancelledError`}},yo=class extends Error{constructor(e,t){super(Ao(e)),this.name=`WorkspaceUploadBatchError`,this.failures=e.map(e=>({...e})),this.responses=t.map(e=>({...e}))}};function bo(e){return e?.uploads?.defaultFolder??`.pi-webui/uploads`}function xo(e,t){return e?.uploads?.defaultFolder??t}function So(e,t){let n=No(e,`upload destination`,{allowEmpty:!0}),r=No(t,`upload file name`,{allowEmpty:!1});return n===``?r:`${n}/${r}`}function Co(e,t,n,r={}){let i=r.xhrFactory?.()??new XMLHttpRequest,a=!1,o=!1;return{promise:new Promise((s,c)=>{let l=e=>{a||(a=!0,c(e))},u=e=>{a||(a=!0,s(e))};i.open(`PUT`,Oa(e,t,n.path,Eo(r)),!0),i.responseType=`json`,i.setRequestHeader(`Content-Type`,(n.contentType??n.file.type)||`application/octet-stream`),i.upload.onprogress=e=>{r.onProgress?.(Do(e,n.file.size))},i.onload=()=>{if(i.status>=200&&i.status<300){try{r.onProgress?.({loaded:n.file.size,total:n.file.size,percent:1,lengthComputable:!0}),u(Gr(Fo(i)))}catch(e){l(e instanceof Error?e:Error(String(e)))}return}l(Error(Io(i)))},i.onerror=()=>{l(Error(`Workspace upload failed`))},i.onabort=()=>{l(new vo(o?void 0:`Workspace upload aborted`))},i.send(n.file)}),cancel:()=>{a||(o=!0,i.abort())}}}function wo(e,t,n,r={}){let i=r.destinationFolder??`.pi-webui/uploads`,a=n.map((e,t)=>({index:t,name:e.name,path:So(i,e.name),loaded:0,total:e.size,percent:ko(0,e.size),lengthComputable:!0,done:!1})),o,s=0,c={requested:!1},l=()=>{r.onProgress?.(Oo(a,s,a.every(e=>e.done)))};return{promise:(async()=>{let i=[],u=[];for(let d=0;d<n.length;d+=1){if(c.requested)throw new vo;s=d;let f=n[d],p=a[d];if(!(f===void 0||p===void 0)){o=Co(e,t,{path:p.path,file:f},{...To(r),onProgress:e=>{p.total=e.total,p.loaded=Math.min(e.loaded,p.total),p.percent=e.percent,p.lengthComputable=e.lengthComputable,l()}});try{let e=await o.promise;p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,i.push(e),l()}catch(e){if(Mo(e,c))throw e;let t=jo(e);p.loaded=p.total,p.percent=1,p.lengthComputable=!0,p.done=!0,p.error=t,u.push({index:d,name:f.name,path:p.path,error:t}),l()}finally{o=void 0}}}if(u.length>0)throw new yo(u,i);return i})(),cancel:()=>{c.requested=!0,o?.cancel()}}}function To(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 Eo(e){return{...e.createDirs===void 0?{}:{createDirs:e.createDirs},...e.overwrite===void 0?{}:{overwrite:e.overwrite},...e.machineId===void 0?{}:{machineId:e.machineId}}}function Do(e,t){let n=e.lengthComputable?e.total:t;return{loaded:e.loaded,total:n,percent:ko(e.loaded,n),lengthComputable:e.lengthComputable}}function Oo(e,t,n){let r=e.reduce((e,t)=>e+t.total,0),i=e.reduce((e,t)=>e+t.loaded,0);return{currentFileIndex:t,files:e.map(e=>({...e})),loaded:i,total:r,percent:ko(i,r),done:n}}function ko(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}function Ao(e){return e.length===1?e[0]?.error??`Workspace upload failed`:`${String(e.length)} files failed to upload`}function jo(e){return e instanceof Error?e.message:String(e)}function Mo(e,t){return t.requested||e instanceof vo}function No(e,t,n){let r=e.trim();if(r===``){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(Po(r))throw Error(`${t} must be workspace-relative`);let i=r.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(i.length===0){if(n.allowEmpty)return``;throw Error(`${t} must not be empty`)}if(i.some(e=>e===`..`))throw Error(`${t} must not contain path traversal`);return i.join(`/`)}function Po(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function Fo(e){return e.response!==void 0&&e.response!==null&&e.response!==``?e.response:e.responseText===``?{}:JSON.parse(e.responseText)}function Io(e){let t=Lo(e);return Ro(t)&&typeof t.error==`string`?t.error:e.statusText||`HTTP ${String(e.status)}`}function Lo(e){try{return Fo(e)}catch{return}}function Ro(e){return typeof e==`object`&&!!e}function zo(){return{sessions:[],projectSessions:[],clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingSessions:!1,selectedNotificationInbox:void 0,treeDialog:void 0,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,selectedTerminalId:void 0,error:``}}function Bo(){return{machines:[],selectedMachine:void 0,isLoadingMachines:!1,machineStatuses:{},machineRuntimes:{},projects:[],workspaces:[],sessions:[],projectSessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,sendingPrompts:{},clientQueuedSessionMessages:{},startingSessionCount:0,isLoadingProjects:!1,isLoadingWorkspaces:!1,isLoadingSessions:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,availableThinkingLevels:[],sessionStatuses:{},sessionActivities:{},workspaceActivities:{},machineActivities:{},selectedNotificationInbox:void 0,workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog:void 0,treeDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,themeDialog:void 0,authDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,machineDialogOpen:!1,workspaceTool:`core:workspace.files`,mainView:`chat`,fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,workspaceUploadBatches:{},gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,activeTerminalCount:0,selectedTerminalId:void 0,piWebUiStatus:void 0,error:``}}function Vo(e,t){return t?.phase===`active`||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function Ho(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}function Uo(e,t){return`${e}:${t}`}function Wo(e,t){return`${e}:${t}`}function R(e){return e.selectedMachine?.id??`local`}var Go=class{constructor(){this.pendingByKey=new Map}request(e,t){let n=this.pendingByKey.get(e);if(n!==void 0)return n.latestRefresh=t,n.started&&(n.trailing=!0),n.promise;let r={promise:Promise.resolve(),latestRefresh:t,started:!1,trailing:!1};return r.promise=Promise.resolve().then(async()=>{let e,t;do{r.trailing=!1;let n=r.latestRefresh;r.started=!0,t=!1;try{await n()}catch(n){e=n,t=!0}}while(this.hasTrailingRequest(r));if(t)throw e}).finally(()=>{this.pendingByKey.get(e)===r&&this.pendingByKey.delete(e)}),this.pendingByKey.set(e,r),r.promise}hasTrailingRequest(e){return e.trailing}},Ko=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.refreshes=new Go,this.api=n.api??to,this.onActivityApplied=n.onActivityApplied}refresh(e=R(this.getState())){return this.refreshes.request(e,async()=>{this.applyMachineActivitySnapshot(e,qo(await this.api.workspaceActivity(e)))})}applyWorkspaceActivity(e,t=R(this.getState())){let n=this.getState(),r=R(n)===t,i=Jo(n.machineActivities[t]??(r?n.workspaceActivities:{}),e);this.setState({machineActivities:{...n.machineActivities,[t]:i},...r?{workspaceActivities:i}:{}}),this.onActivityApplied?.(t)}applyMachineActivitySnapshot(e,t){let n=this.getState();this.setState({machineActivities:{...n.machineActivities,[e]:t},...R(n)===e?{workspaceActivities:t}:{}}),this.onActivityApplied?.(e)}};function qo(e){let t={};for(let n of e.workspaces)Ho(n)&&(t[n.cwd]=n);return t}function Jo(e,t){let n={...e};return Ho(t)?(n[t.cwd]=t,n):Object.fromEntries(Object.entries(n).filter(([e])=>e!==t.cwd))}var Yo=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.applyStatus=n,this.oauthOperationGeneration=0,this.pollGeneration=0,this.api=r.api??L,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.oauthOperationGeneration+=1,this.stopPolling()}handleSlashCommand(e){let t=Zo(e);return t===void 0?!1:(t.command===`login`?this.openLogin(t.providerId):this.openLogout(t.providerId),!0)}async openLogin(e){if(e!==void 0&&e!==``){await this.openLoginProvider(e);return}this.setState({authDialog:{step:`method`}})}async chooseLoginMethod(e){try{let{providers:t}=await this.api.authProviders({mode:`login`,authType:e,machineId:R(this.getState())});this.setState({authDialog:{step:`providers`,mode:`login`,authType:e,providers:t}})}catch(e){this.setState({error:String(e)})}}async selectLoginProvider(e,t){let n=this.getState().authDialog;if(n?.step!==`providers`)return;let r=n.providers.find(n=>n.id===e&&(t===void 0||n.authType===t));r!==void 0&&(r.authType===`oauth`||r.loginFlow===`interactive`?await this.startLoginFlow(r):this.setState({authDialog:{step:`apiKey`,provider:r,value:``}}))}updateApiKey(e){let t=this.getState().authDialog;if(t?.step!==`apiKey`)return;let n={...t};delete n.error,this.setState({authDialog:{...n,value:e}})}async saveApiKey(){let e=this.getState().authDialog;if(e?.step!==`apiKey`)return;let t=e.value.trim();if(t===``){this.setState({authDialog:{...e,error:`API key is required`}});return}let n={...e};delete n.error,this.setState({authDialog:{...n,saving:!0}});try{await this.api.saveApiKey(e.provider.id,t,R(this.getState())),this.closeDialog(),this.refreshStatus()}catch(t){this.setState({authDialog:{...e,saving:!1,error:String(t)}})}}async openLogout(e){try{let{providers:t}=await this.api.authProviders({mode:`logout`,machineId:R(this.getState())});if(e!==void 0&&e!==``){let n=t.find(t=>t.id===e);n!==void 0&&!this.rejectRemoteOAuth(`logout`,n)?await this.logoutProvider(n.id):n===void 0&&this.setState({error:`No stored credentials for ${e}`});return}this.setState({authDialog:{step:`logout`,providers:t}})}catch(e){this.setState({error:String(e)})}}async logoutProvider(e){let t=this.getState().authDialog,n=t?.step===`logout`?t.providers.find(t=>t.id===e):void 0;if(!(n!==void 0&&this.rejectRemoteOAuth(`logout`,n)))try{await this.api.logoutProvider(e,R(this.getState())),this.closeDialog(),this.refreshStatus()}catch(e){this.setState({error:String(e)})}}updateOAuthInput(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n={...t};delete n.error,this.setState({authDialog:{...n,inputValue:e}})}async respondOAuth(e){let t=this.getState().authDialog;if(t?.step!==`oauth`)return;let n=t.flow.prompt??t.flow.select;if(n===void 0)return;let r=this.oauthOperationGeneration,i=t.flow.flowId,a=n.requestId,o=e??t.inputValue??``,s={...t};delete s.error,this.setState({authDialog:{...s,responding:!0}});try{let e=await this.api.respondOAuthFlow(i,a,o,t.machineId),n=this.currentOAuthDialog(r,i);if(e.flowId!==i||n===void 0||Xo(n.flow)!==a)return;this.updateOAuthFlow(e,n.machineId)}catch(e){let t=this.currentOAuthDialog(r,i);if(t===void 0||Xo(t.flow)!==a)return;this.setState({authDialog:{...t,responding:!1,error:String(e)}})}}async cancelOAuth(){let e=this.getState().authDialog;if(e?.step!==`oauth`){this.closeDialog();return}let t=e.flow.flowId,n=e.machineId;this.closeDialog();try{await this.api.cancelOAuthFlow(t,n)}catch{}}closeDialog(){this.oauthOperationGeneration+=1,this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(e){try{let{providers:t}=await this.api.authProviders({mode:`login`,machineId:R(this.getState())}),n=t.filter(t=>t.id===e);if(n.length===0){this.setState({error:`Auth provider not found: ${e}`});return}if(n.length>1){this.setState({authDialog:{step:`providers`,mode:`login`,providers:n}});return}let r=n[0];if(r===void 0)return;r.authType===`oauth`||r.loginFlow===`interactive`?await this.startLoginFlow(r):this.setState({authDialog:{step:`apiKey`,provider:r,value:``}})}catch(e){this.setState({error:String(e)})}}async startLoginFlow(e){if(this.rejectRemoteOAuth(`login`,e))return;let t=++this.oauthOperationGeneration;this.stopPolling();try{let n=R(this.getState()),r=e.authType===`oauth`?await this.api.startOAuthLogin(e.id,n):await this.api.startInteractiveApiKeyLogin(e.id,n);if(t!==this.oauthOperationGeneration){if(r.status===`running`)try{await this.api.cancelOAuthFlow(r.flowId,n)}catch{}return}this.updateOAuthFlow(r,n),r.status===`running`&&this.startPolling(r.flowId,n)}catch(e){t===this.oauthOperationGeneration&&this.setState({error:String(e)})}}rejectRemoteOAuth(e,t){let n=this.getState().selectedMachine;if(t.authType!==`oauth`||n?.kind!==`remote`)return!1;let r=n.baseUrl??`that remote PI WEBUI instance`;return this.setState({error:`OAuth ${e} for remote machines must be configured directly on ${r}.`}),!0}updateOAuthFlow(e,t){if(e.status===`complete`){this.stopPolling(),this.closeDialog(),this.refreshStatus(t);return}(e.status===`error`||e.status===`cancelled`)&&(this.oauthOperationGeneration+=1,this.stopPolling());let n=this.getState().authDialog,r=n?.step===`oauth`&&n.flow.flowId===e.flowId?n.inputValue??``:``,i=n?.step===`oauth`?Xo(n.flow):void 0,a=Xo(e),o=i!==void 0&&i===a,s=o?r:``,c=o&&n?.step===`oauth`?n.responding===!0:!1;this.setState({authDialog:{step:`oauth`,flow:e,machineId:t,inputValue:s,responding:c}})}startPolling(e,t){this.stopPolling();let n=this.oauthOperationGeneration,r=this.pollGeneration;this.pollTimer=window.setInterval(()=>{this.poll(e,t,n,r)},this.pollIntervalMs)}stopPolling(){this.pollGeneration+=1,this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(e,t,n,r){if(r!==this.pollGeneration)return;let i=this.currentOAuthDialog(n,e);if(i?.machineId!==t){this.stopPolling();return}let a=Xo(i.flow);try{let i=await this.api.oauthFlow(e,t),o=this.currentOAuthDialog(n,e);if(i.flowId!==e||r!==this.pollGeneration||o?.machineId!==t||Xo(o.flow)!==a)return;this.updateOAuthFlow(i,t)}catch(i){let o=this.currentOAuthDialog(n,e);if(r!==this.pollGeneration||o?.machineId!==t||Xo(o.flow)!==a)return;this.stopPolling(),this.setState({authDialog:{...o,error:String(i)}})}}currentOAuthDialog(e,t){if(e!==this.oauthOperationGeneration)return;let n=this.getState().authDialog;return n?.step===`oauth`&&n.flow.flowId===t?n:void 0}async refreshStatus(e=R(this.getState())){let t=this.selectedSessionForMachine(e);if(t!==void 0)try{let n=await this.api.status(t,e),r=this.selectedSessionForMachine(e);if(r?.id!==t.id||r.cwd!==t.cwd)return;this.applyStatus(n)}catch{}}selectedSessionForMachine(e){let t=this.getState();if(R(t)!==e)return;let n=t.selectedSession;if(!(n===void 0||n.archived===!0))return n}};function Xo(e){return e.prompt?.requestId??e.select?.requestId}function Zo(e){let t=e.trim(),n=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(n===null)return;let r=n[1];if(r!==`login`&&r!==`logout`)return;let i=n[2];return i===void 0||i===``?{command:r}:{command:r,providerId:i}}function Qo(e){return e.replaceAll(`:`,`.`)}function $o(e){let t=new URLSearchParams(window.location.search),n=`${e}--`,r={};for(let[e,i]of t.entries()){if(!e.startsWith(n))continue;let t=e.slice(n.length),a=r[t];a===void 0?r[t]=i:Array.isArray(a)?a.push(i):r[t]=[a,i]}return r}function es(e,t){let n=$o(e)[t];return Array.isArray(n)?n[0]:n===``?void 0:n}function ts(e,t,n,r){let i=new URL(window.location.href),a=`${e}--${t}`;if(i.searchParams.delete(a),n!=null&&n!==``)if(Array.isArray(n))for(let e of n)i.searchParams.append(a,String(e));else i.searchParams.set(a,String(n));ns(i,r)}function ns(e,t){`${e.pathname}${e.search}${e.hash}`!=`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t?.replace===!0?window.history.replaceState({},``,e):window.history.pushState({},``,e))}function rs(e){let t=e.files.map((t,n)=>{let r=t.size;return{index:n,name:t.name,path:So(e.destinationFolder,t.name),size:t.size,loaded:0,total:r,percent:ls(0,r),lengthComputable:!0,status:n===0?`uploading`:`pending`}}),n=t.reduce((e,t)=>e+t.total,0);return{id:e.id,projectId:e.projectId,workspaceId:e.workspaceId,machineId:e.machineId,destinationFolder:e.destinationFolder,overwrite:e.overwrite,createDirs:e.createDirs,files:t,currentFileIndex:t.length===0?-1:0,loaded:0,total:n,percent:ls(0,n),status:`uploading`,startedAt:e.startedAt}}function is(e,t){let n=new Map(t.files.map(e=>[e.index,e])),r=e.files.map(e=>{let r=n.get(e.index);if(r===void 0)return e;let i={...e,path:r.path,loaded:r.loaded,total:r.total,percent:r.percent,lengthComputable:r.lengthComputable,status:r.error===void 0?r.done?`completed`:t.currentFileIndex===e.index?`uploading`:e.status:`error`};return r.error===void 0?delete i.error:i.error=r.error,i});return{...e,files:r,currentFileIndex:t.currentFileIndex,loaded:t.loaded,total:t.total,percent:t.percent}}function as(e,t,n){let r=e.files.map((e,n)=>{let r=t[n];return{...e,...r===void 0?{}:{path:r.path,response:r},loaded:e.total,percent:1,lengthComputable:!0,status:`completed`}}),i=cs(r);return{...e,files:r,currentFileIndex:r.length===0?-1:r.length-1,...i,status:`completed`,completedAt:n}}function os(e,t,n){let r=e.files.map(n=>n.status===`completed`||n.status===`error`?n:n.status===`uploading`||n.index===e.currentFileIndex?{...n,status:`error`,error:t}:{...n,status:`cancelled`,error:`Not uploaded because an earlier file failed.`});return{...e,files:r,...cs(r),status:`error`,error:t,completedAt:n}}function ss(e,t){let n=`Upload cancelled`,r=e.files.map(e=>e.status===`completed`||e.status===`error`?e:{...e,status:`cancelled`,error:n});return{...e,files:r,...cs(r),status:`cancelled`,error:n,completedAt:t}}function cs(e){let t=e.reduce((e,t)=>e+t.total,0);return{loaded:t,total:t,percent:e.length===0?0:1}}function ls(e,t){return t<=0?e<=0?0:1:Math.max(0,Math.min(1,e/t))}var us=Qo(`core:workspace.files`),ds=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.updateUrl=n,this.uploadTasks=new Map,this.uploadBatchSequence=0,this.api=r.api??L,this.uploadWorkspaceFiles=r.uploadWorkspaceFiles??wo,this.createUploadBatchId=r.createUploadBatchId??(()=>(this.uploadBatchSequence+=1,`workspace-upload-${String(this.uploadBatchSequence)}`)),this.now=r.now??(()=>new Date().toISOString())}async refreshFiles(){let e=this.getState().selectedProject,t=this.getState().selectedWorkspace;if(!(e===void 0||t===void 0))try{let n=R(this.getState()),r=await this.api.workspaceTree(e.id,t.id,``,n),i={...this.getState().expandedDirs};await Promise.all(Object.keys(i).map(async r=>{i[r]=(await this.api.workspaceTree(e.id,t.id,r,n)).entries})),this.setState({fileTree:r.entries,expandedDirs:i,fileTreeStale:!1,error:``})}catch(e){this.setState({error:String(e)})}}async expandDir(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0)){if(this.getState().expandedDirs[e]!==void 0){this.setState({expandedDirs:hs(this.getState().expandedDirs,e)});return}try{let r=await this.api.workspaceTree(t.id,n.id,e,R(this.getState()));this.setState({expandedDirs:{...this.getState().expandedDirs,[e]:r.entries},error:``})}catch(e){this.setState({error:String(e)})}}}async selectFile(e){this.setState({selectedFilePath:e,selectedFileContent:void 0,workspaceTool:`core:workspace.files`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.files`}),ts(us,`file`,e),this.updateUrl({replace:!0}),await this.restoreFile(e)}async restoreFile(e){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(!(t===void 0||n===void 0)){this.setState({selectedFilePath:e,selectedFileContent:void 0});try{let r=await this.api.workspaceFile(t.id,n.id,e,R(this.getState()));this.getState().selectedFilePath===e&&this.setState({selectedFileContent:r,error:``})}catch(t){if(this.getState().selectedFilePath!==e)return;if(fs(t)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:``}),ts(us,`file`,void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(t)})}}}startWorkspaceUpload(e,t){let n=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(n===void 0||r===void 0){this.setState({error:`Select a workspace before uploading files.`});return}if(e.length===0)return;let i=R(this.getState()),a=t.overwrite??!1,o=t.createDirs??!0,s;try{s=rs({id:this.createUploadBatchId(),projectId:n.id,workspaceId:r.id,machineId:i,destinationFolder:t.destinationFolder,overwrite:a,createDirs:o,files:e,startedAt:this.now()})}catch(e){this.setState({error:String(e)});return}this.setUploadBatch(s);let c;try{c=this.uploadWorkspaceFiles(n.id,r.id,e,{destinationFolder:t.destinationFolder,machineId:i,overwrite:a,createDirs:o,onProgress:e=>{this.updateUploadProgress(s.id,e)}})}catch(e){return this.failUploadBatch(s.id,e),{batchId:s.id,done:Promise.resolve()}}this.uploadTasks.set(s.id,c);let l=c.promise.then(async e=>{await this.completeUploadBatch(s.id,e,t)}).catch(async e=>{await this.handleUploadFailure(s.id,e,t)}).finally(()=>{this.uploadTasks.delete(s.id)});return{batchId:s.id,done:l}}cancelWorkspaceUpload(e){let t=this.getUploadBatch(e);t?.status===`uploading`&&(this.setUploadBatch(ss(t,this.now())),this.uploadTasks.get(e)?.cancel())}clearWorkspaceUpload(e){this.uploadTasks.get(e)?.cancel(),this.uploadTasks.delete(e),this.setState({workspaceUploadBatches:hs(this.getState().workspaceUploadBatches,e)})}updateUploadProgress(e,t){let n=this.getUploadBatch(e);n?.status===`uploading`&&this.setUploadBatch(is(n,t))}async completeUploadBatch(e,t,n){let r=this.getUploadBatch(e);if(r?.status!==`uploading`||(this.setUploadBatch(as(r,t,this.now()),{error:``}),!this.isCurrentWorkspaceBatch(r)))return;await this.refreshFiles();let i=t[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}async handleUploadFailure(e,t,n){let r=this.failUploadBatch(e,t);if(!(t instanceof yo)||t.responses.length===0||r===void 0||!this.isCurrentWorkspaceBatch(r))return;await this.refreshFiles();let i=t.responses[0]?.path;n.selectUploadedFile!==!1&&i!==void 0&&this.isCurrentWorkspaceBatch(r)&&await this.selectFile(i)}failUploadBatch(e,t){let n=this.getUploadBatch(e);if(n?.status!==`uploading`)return;if(ps(t)){let e=ss(n,this.now());return this.setUploadBatch(e),e}let r=ms(t),i=os(n,r,this.now());return this.setUploadBatch(i,{error:r}),i}getUploadBatch(e){return this.getState().workspaceUploadBatches[e]}setUploadBatch(e,t={}){this.setState({workspaceUploadBatches:{...this.getState().workspaceUploadBatches,[e.id]:e},...t})}isCurrentWorkspaceBatch(e){let t=this.getState();return t.selectedProject?.id===e.projectId&&t.selectedWorkspace?.id===e.workspaceId&&R(t)===e.machineId}};function fs(e){let t=String(e);return t.includes(`Path does not exist`)||t.includes(`ENOENT`)||t.includes(`no such file or directory`)}function ps(e){return e instanceof vo}function ms(e){return e instanceof Error?e.message:String(e)}function hs(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}var gs=Qo(`core:workspace.git`),_s=class{constructor(e,t,n){this.getState=e,this.setState=t,this.updateUrl=n,this.statusRequest=0,this.diffRequest=0}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0,this.pollingScope=void 0,this.statusRequest+=1,this.diffRequest+=1}async refreshGit(e={}){let t=this.getState().selectedProject,n=this.getState().selectedWorkspace;if(t===void 0||n===void 0)return;let r=R(this.getState()),i=++this.statusRequest;this.diffRequest+=1;try{let a=await L.gitStatus(t.id,n.id,r);if(i!==this.statusRequest||!this.isCurrentWorkspace(t,n,r))return;this.setState({gitStatus:a,gitStale:!1,...e.reportError===!1?{}:{error:``}});let o=this.getState().selectedDiffPath;o!==void 0&&(a.files.some(e=>e.path===o)?await this.refreshDiff(o,e):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),ts(gs,`diff`,void 0,{replace:!0})))}catch(a){if(i!==this.statusRequest||!this.isCurrentWorkspace(t,n,r))return;e.reportError!==!1&&this.setState({error:String(a)})}}async selectDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:`core:workspace.git`,mainView:this.getState().mainView===`chat`?`chat`:`core:workspace.git`}),ts(gs,`diff`,e),this.updateUrl({replace:!0}),await this.refreshDiff(e)}async restoreDiff(e){this.setState({selectedDiffPath:e,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(e)}async refreshDiff(e,t={}){let n=this.getState().selectedProject,r=this.getState().selectedWorkspace;if(n===void 0||r===void 0)return;let i=R(this.getState()),a=++this.diffRequest;try{let[o,s]=await Promise.all([L.gitDiff(n.id,r.id,{path:e},i),L.gitDiff(n.id,r.id,{path:e,staged:!0},i)]);if(a!==this.diffRequest||!this.isCurrentWorkspace(n,r,i))return;this.setState({selectedDiff:o,selectedStagedDiff:s,...t.reportError===!1?{}:{error:``}})}catch(e){if(a!==this.diffRequest||!this.isCurrentWorkspace(n,r,i))return;t.reportError!==!1&&this.setState({error:String(e)})}}updatePolling(){let e=this.currentPollingScope();e===this.pollingScope&&this.pollTimer!==void 0||(this.dispose(),e!==void 0&&(this.pollingScope=e,this.refreshGit({reportError:!1}),this.pollTimer=window.setInterval(()=>{this.refreshGit({reportError:!1})},8e3)))}currentPollingScope(){let e=this.getState();if(!(e.selectedProject===void 0||e.selectedWorkspace?.isGitRepo!==!0))return JSON.stringify([R(e),e.selectedProject.id,e.selectedWorkspace.id])}isCurrentWorkspace(e,t,n){let r=this.getState();return R(r)===n&&r.selectedProject?.id===e.id&&r.selectedWorkspace?.id===t.id&&r.selectedWorkspace.projectId===t.projectId}};function vs(e){let t=[],n=[];for(let r of e)ws(r.index)&&t.push(Cs(r,`staged`,r.index)),Ts(r.workingTree)&&n.push(Cs(r,`unstaged`,r.workingTree));return{staged:t,unstaged:n}}function ys(e){let t=vs(e);return new Set([...t.staged,...t.unstaged].map(e=>e.path)).size}function bs(e){switch(e){case`modified`:return`M`;case`added`:return`A`;case`deleted`:return`D`;case`renamed`:return`R`;case`copied`:return`C`;case`untracked`:return`?`;case`conflicted`:return`U`;case`ignored`:return`!`;case`unmodified`:return``}}function xs(e){switch(e){case`modified`:return`Modified`;case`added`:return`Added`;case`deleted`:return`Deleted`;case`renamed`:return`Renamed`;case`copied`:return`Copied`;case`untracked`:return`Untracked`;case`conflicted`:return`Conflicted`;case`ignored`:return`Ignored`;case`unmodified`:return`Unmodified`}}function Ss(e){return e.oldPath===void 0?e.path:`${e.oldPath} → ${e.path}`}function Cs(e,t,n){return{id:`${t}:${e.path}`,path:e.path,...e.oldPath===void 0?{}:{oldPath:e.oldPath},scope:t,state:n}}function ws(e){return e!==`unmodified`&&e!==`untracked`&&e!==`ignored`&&e!==`conflicted`}function Ts(e){return e!==`unmodified`&&e!==`ignored`}var Es=class{constructor(e,t,n,r){this.getState=e,this.setState=t,this.updateUrl=n,this.projects=r,this.runtimeRefreshSeqByMachine=new Map}async loadMachines(e){this.setState({error:``,isLoadingMachines:!0});try{let t=await L.machines(),n=await this.selectInitialMachine(t,e),r=new Set(t.map(e=>e.id));this.setState({machines:t,selectedMachine:n,machineActivities:Os(this.getState().machineActivities,r),machineRuntimes:Os(this.getState().machineRuntimes,r)}),this.refreshMachineHealthFor(t),this.refreshMachineRuntimeFor(t)}catch(e){this.setState({error:String(e)})}finally{this.setState({isLoadingMachines:!1})}}async selectMachine(e,t={}){this.getState().selectedMachine?.id!==e.id&&(this.setState({selectedMachine:e,projects:[],workspaces:[],isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,messages:[],messagePageStart:0,messagePageTotal:0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},sendingPrompts:{},workspaceActivities:{},workspacesByProjectId:{},workspaceDeletionRuns:{},activeTerminalCount:0,...zo()}),t.updateUrl!==!1&&this.updateUrl(),await this.projects.loadProjects(),this.refreshMachineHealth(e.id),this.refreshMachineRuntime(e.id))}async addMachine(e){this.setState({error:``});try{let t=await L.addMachine(e);return this.setState({machines:[...this.getState().machines.filter(e=>e.id!==t.id),t]}),await this.selectMachine(t),t}catch(e){this.setState({error:String(e)});return}}async deleteMachine(e=this.getState().selectedMachine,t={}){if(e!==void 0){if(e.kind===`local`){this.setState({error:`The local machine cannot be removed.`});return}try{let n=this.getState().selectedMachine?.id===e.id;await L.deleteMachine(e.id);let r=this.getState().machines.filter(t=>t.id!==e.id),i=r.find(e=>e.id===`local`)??r[0];return this.setState({machines:r,machineStatuses:Ds(this.getState().machineStatuses,e.id),machineRuntimes:Ds(this.getState().machineRuntimes,e.id),machineActivities:Ds(this.getState().machineActivities,e.id)}),n&&i!==void 0?(t.selectFallback===!1||await this.selectMachine(i),i):void 0}catch(e){this.setState({error:String(e)});return}}}async refreshMachineHealth(e=this.getState().selectedMachine?.id??`local`){try{let t=await L.health(e);return this.setState({machineStatuses:{...this.getState().machineStatuses,[t.machineId]:t}}),t}catch(e){this.setState({error:String(e)});return}}async refreshMachineRuntime(e=this.getState().selectedMachine?.id??`local`){let t=(this.runtimeRefreshSeqByMachine.get(e)??0)+1;this.runtimeRefreshSeqByMachine.set(e,t);try{let n=await L.runtime(e,!0);return this.runtimeRefreshSeqByMachine.get(e)===t?(this.setState({machineRuntimes:{...this.getState().machineRuntimes,[n.machineId]:n}}),n):void 0}catch(n){this.runtimeRefreshSeqByMachine.get(e)===t&&this.setState({error:String(n)});return}}async selectInitialMachine(e,t){let n=e.find(e=>e.id===(t??`local`));if(n===void 0)return this.localMachine(e);if(n.kind!==`remote`)return n;let r=await this.safeRemoteHealth(n);return this.setState({machineStatuses:{...this.getState().machineStatuses,[r.machineId]:r},...r.ok?{}:{error:`${n.name} is unavailable; reconnecting…`}}),n}async safeRemoteHealth(e){try{return await L.health(e.id)}catch(t){return{machineId:e.id,ok:!1,checkedAt:new Date().toISOString(),status:`offline`,error:t instanceof Error?t.message:String(t)}}}localMachine(e){return e.find(e=>e.id===`local`)??e[0]}async refreshMachineHealthFor(e){let t=await Promise.allSettled(e.map(e=>L.health(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineStatuses:{...this.getState().machineStatuses,...n}})}async refreshMachineRuntimeFor(e){let t=await Promise.allSettled(e.map(e=>L.runtime(e.id))),n=Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[[e.value.machineId,e.value]]:[]));Object.keys(n).length>0&&this.setState({machineRuntimes:{...this.getState().machineRuntimes,...n}})}};function Ds(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function Os(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)))}var ks=`~/workspace`,As=class{constructor(e,t,n,r={}){this.getState=e,this.setState=t,this.workspaces=n,this.api=r.api??L,this.onProjectsApplied=r.onProjectsApplied}async loadProjects(){let e=R(this.getState());this.setState({error:``,isLoadingProjects:!0});try{let t=await this.api.projects(e);if(R(this.getState())!==e)return;let n;if(t.length===0){if(n=await this.api.addProject(ks,void 0,!0,e),R(this.getState())!==e)return;t=[n]}let r=new Set(t.map(e=>e.id)),i=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([e])=>r.has(e)));this.setState({projects:t,workspacesByProjectId:i}),this.onProjectsApplied?.(e),n!==void 0&&await this.workspaces.selectProject(n)}catch(t){R(this.getState())===e&&this.setState({error:String(t)})}finally{R(this.getState())===e&&this.setState({isLoadingProjects:!1})}}async addProject(e,t){if(e.trim()===``)return;let n=R(this.getState());try{let r=await this.api.addProject(e.trim(),void 0,t,n);if(R(this.getState())!==n)return;let i=this.getState().projects;this.setState({projects:[...i.filter(e=>e.id!==r.id),r],projectDialogOpen:!1}),this.onProjectsApplied?.(n),await this.workspaces.selectProject(r)}catch(e){R(this.getState())===n&&this.setState({error:String(e)})}}async closeProject(e){let t=R(this.getState());try{if(await this.api.closeProject(e,t),R(this.getState())!==t)return;this.workspaces.forgetProject(e);let n=this.getState();this.setState({projects:n.projects.filter(t=>t.id!==e)}),this.onProjectsApplied?.(t),n.selectedProject?.id===e&&this.workspaces.clearSelection()}catch(e){R(this.getState())===t&&this.setState({error:String(e)})}}};function js(e,t){return t[e.path]}function Ms(e){if(e?.hasSessionActivity===!0)return`session`;if(e?.hasTerminalActivity===!0)return`terminal`}function Ns(e,t,n){return Is(Ls(e,t,n))}function Ps(e,t,n){return t.some(t=>t.projectId===e.id&&t.path===n)||n===e.path||n.startsWith(`${e.path}/`)}function Fs(e){return Is(Object.values(e??{}))}function Is(e){if(e.some(e=>e.hasSessionActivity))return`session`;if(e.some(e=>e.hasTerminalActivity))return`terminal`}function Ls(e,t,n){return Object.values(n).filter(n=>Ps(e,t,n.cwd))}var Rs=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.machineGeneration=0,this.activityMachineGeneration=-1,this.projectTopologyGeneration=0,this.nextCwdActivation=0,this.observedActiveCwds=new Set,this.cwdActivations=new Map,this.attemptedCwdActivations=new Map,this.api=n.api??ro,this.onError=n.onError}handleActivityApplied(e){return R(this.getState())===e?(this.activityMachineGeneration=this.machineGeneration,this.reconcile(e)):Promise.resolve()}handleProjectsApplied(e){return R(this.getState())!==e||(this.projectTopologyGeneration+=1,this.attemptedCwdActivations.clear(),this.activePass=void 0,this.activityMachineGeneration!==this.machineGeneration)?Promise.resolve():this.reconcile(e)}handleSelectedMachineChanged(){this.machineGeneration+=1,this.projectTopologyGeneration+=1,this.observedActiveCwds.clear(),this.cwdActivations.clear(),this.attemptedCwdActivations.clear(),this.activePass=void 0}reconcile(e){let t=this.getState();if(R(t)!==e)return Promise.resolve();let n=this.syncActiveCwds(t),r=new Map([...n].filter(([e,n])=>!zs(t.projects,t.workspacesByProjectId,e)&&this.attemptedCwdActivations.get(e)!==n)),i=this.activePass;if(i!==void 0)return(i.machineGeneration!==this.machineGeneration||i.projectTopologyGeneration!==this.projectTopologyGeneration||[...r].some(([e,t])=>i.cwdActivations.get(e)!==t))&&(i.trailingRequested=!0),i.promise;if(r.size===0||t.projects.length===0)return Promise.resolve();let a={machineGeneration:this.machineGeneration,projectTopologyGeneration:this.projectTopologyGeneration,machineId:e,projects:t.projects.map(e=>({id:e.id,path:e.path,startingWorkspaces:t.workspacesByProjectId[e.id]})),cwdActivations:r,trailingRequested:!1,promise:Promise.resolve()};return this.activePass=a,a.promise=this.runPass(a),a.promise}async runPass(e){if(await Promise.all(e.projects.map(async t=>{try{let n=await this.api.workspaces(t.id,e.machineId);this.applyProjectWorkspaces(e,t,n)}catch(n){this.isPassScopeCurrent(e)&&this.reportError({machineId:e.machineId,projectId:t.id,error:n})}})),this.activePass!==e)return;let t=this.getState(),n=this.syncActiveCwds(t);for(let[r,i]of e.cwdActivations)n.get(r)===i&&!zs(t.projects,t.workspacesByProjectId,r)&&this.attemptedCwdActivations.set(r,i);let r=e.trailingRequested;this.activePass=void 0,r&&await this.reconcile(R(this.getState()))}applyProjectWorkspaces(e,t,n){if(this.activePass!==e||!this.isPassScopeCurrent(e))return;let r=this.getState();r.projects.find(e=>e.id===t.id)?.path===t.path&&r.workspacesByProjectId[t.id]===t.startingWorkspaces&&this.setState({workspacesByProjectId:{...r.workspacesByProjectId,[t.id]:n}})}isPassScopeCurrent(e){return e.machineGeneration===this.machineGeneration&&e.projectTopologyGeneration===this.projectTopologyGeneration&&R(this.getState())===e.machineId}syncActiveCwds(e){let t=new Set(Object.values(e.workspaceActivities).filter(Ho).map(e=>e.cwd));for(let e of this.observedActiveCwds)t.has(e)||(this.cwdActivations.delete(e),this.attemptedCwdActivations.delete(e));for(let e of t)this.observedActiveCwds.has(e)||(this.nextCwdActivation+=1,this.cwdActivations.set(e,this.nextCwdActivation),this.attemptedCwdActivations.delete(e));return this.observedActiveCwds=t,new Map([...t].map(e=>[e,this.cwdActivations.get(e)??0]))}reportError(e){if(this.onError!==void 0)try{this.onError(e)}catch{}}};function zs(e,t,n){return e.some(e=>Ps(e,t[e.id]??[],n))}var Bs=class{constructor(e,t,n={}){this.getState=e,this.setState=t,this.requestSequence=0,this.api=n.api??za,this.onRefreshError=n.onRefreshError??(()=>void 0)}async refresh(){let e=R(this.getState());if(this.pendingUpdateCheck?.machineId===e)return;let t=++this.requestSequence;try{let n=await this.api.piWebUiStatus(e);this.isCurrent(e,t)&&this.setState({piWebUiStatus:n})}catch(n){if(!this.isCurrent(e,t))return;this.setState({piWebUiStatus:void 0}),this.onRefreshError(e,n)}}checkForUpdates(){let e=R(this.getState()),t=this.pendingUpdateCheck;if(t?.machineId===e)return t.promise;let n=++this.requestSequence,r=this.api.checkForUpdates(e).then(t=>{this.isCurrent(e,n)&&(this.setState({piWebUiStatus:t}),Vs(t))}).catch(t=>{if(this.isCurrent(e,n))throw t}).finally(()=>{this.pendingUpdateCheck?.requestSequence===n&&(this.pendingUpdateCheck=void 0)});return this.pendingUpdateCheck={machineId:e,requestSequence:n,promise:r},r}isCurrent(e,t){return R(this.getState())===e&&t===this.requestSequence}};function Vs(e){if(e.release.error!==void 0)throw Error(`PI WEBUI update check failed: ${e.release.error}`);if(e.release.skipped===!0)throw Error(`PI WEBUI update check was skipped because remote version checks are disabled by offline/version-check settings`)}var Hs=`pi-webui:cached-new-sessions:v1`,Us=`browserCachedNew`,Ws=`local`;function Gs(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function Ks(e,t=Ws,n=Gs()){if(e.messageCount!==0||e.archived===!0)return;let r=Qs(n).filter(n=>n.id!==e.id||n.machineId!==t);$s([qs(e,t),...r],n)}function qs(e,t=Ws){return{...e,browserCachedNew:!0,machineId:t}}function Js(e,t=Ws,n=Gs()){$s(Qs(n).filter(n=>n.id!==e||n.machineId!==t),n)}function Ys(e,t,n=Ws,r=Gs()){let i=new Set(t.map(e=>e.id)),a=Qs(r),o=a.filter(e=>e.machineId!==n||!i.has(e.id));return o.length!==a.length&&$s(o,r),[...o.filter(t=>t.machineId===n&&t.cwd===e),...t]}function Xs(e){return e!==void 0&&tc(e)&&e.browserCachedNew===!0}function Zs(e){return{id:e.id,path:e.path,cwd:e.cwd,...e.persisted===void 0?{}:{persisted:e.persisted},...e.name===void 0?{}:{name:e.name},created:e.created,modified:e.modified,messageCount:e.messageCount,firstMessage:e.firstMessage,...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath},...`machineId`in e&&typeof e.machineId==`string`?{machineId:e.machineId}:{machineId:Ws},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function Qs(e=Gs()){try{let t=e?.getItem(Hs);if(t==null||t===``)return[];let n=JSON.parse(t);return Array.isArray(n)?n.flatMap(e=>ec(e)):[]}catch{return[]}}function $s(e,t=Gs()){try{e.length===0?t?.removeItem(Hs):t?.setItem(Hs,JSON.stringify(e))}catch{}}function ec(e){if(!nc(e))return[];let t=rc(e,`id`),n=rc(e,`path`),r=rc(e,`cwd`),i=rc(e,`created`),a=rc(e,`modified`),o=rc(e,`firstMessage`),s=ac(e,`messageCount`);if(t===void 0||n===void 0||r===void 0||i===void 0||a===void 0||o===void 0||s!==0)return[];let c=ic(e,`name`),l=ic(e,`parentSessionPath`),u=ic(e,`machineId`)??Ws;return[{id:t,path:n,cwd:r,...c===void 0?{}:{name:c},created:i,modified:a,messageCount:s,firstMessage:o,...l===void 0?{}:{parentSessionPath:l},machineId:u,browserCachedNew:!0}]}function tc(e){return Us in e}function nc(e){return typeof e==`object`&&!!e}function rc(e,t){let n=e[t];return typeof n==`string`?n:void 0}function ic(e,t){let n=e[t];return n===void 0||typeof n!=`string`?void 0:n}function ac(e,t){let n=e[t];return typeof n==`number`?n:void 0}function oc(e){return Tc(e.flatMap(dc)).filter(e=>e.parts.length>0)}function sc(e,t){return{role:e,parts:[{type:`text`,text:t}]}}function cc(e,t){let n=_c(t),r=z(t,`entryId`),i=z(t,`previousAssistantEntryId`),a=Pc(t,`canFork`);return{...e,...n===void 0?{}:{meta:n},...r===void 0?{}:{entryId:r},...i===void 0?{}:{previousAssistantEntryId:i},...a===void 0?{}:{canFork:a}}}function lc(e,t,n){if(n===``)return e;let r=e.at(-1),i=r?.parts.at(-1);return r?.role===t&&i?.type===`text`?[...e.slice(0,-1),{...r,parts:[...r.parts.slice(0,-1),{...i,text:i.text+n}]}]:r?.role===t?[...e.slice(0,-1),{...r,parts:[...r.parts,{type:`text`,text:n}]}]:[...e,sc(t,n)]}function uc(e,t){if(t===``)return e;let n=e.at(-1),r=n?.parts.at(-1);return n?.role===`assistant`&&r?.type===`thinking`?[...e.slice(0,-1),{...n,parts:[...n.parts.slice(0,-1),{...r,text:r.text+t}]}]:n?.role===`assistant`?[...e.slice(0,-1),{...n,parts:[...n.parts,{type:`thinking`,text:t}]}]:[...e,{role:`assistant`,parts:[{type:`thinking`,text:t}]}]}function dc(e){if(pc(e))return[e];if(z(e,`role`)===`bashExecution`)return[cc(bc(e),e)];let t=xc(z(e,`role`)),n=Sc(Nc(e,`content`),e),r=t===`user`?mc(n):void 0;if(r!==void 0)return r.map(t=>cc(t,e));let i=gc(e);if(t===`tool`)return[cc({role:t,parts:n,...i===void 0?{}:{source:i}},e)];let a=n.filter(e=>e.type!==`empty`),o=t===`assistant`&&a.length>0&&a.every(e=>e.type===`skillRead`)?`skill`:t,s=a.length>0?[cc({role:o,parts:a,...i===void 0?{}:{source:i}},e)]:[],c=fc(e);return c===void 0?s:[...s,cc(c,e)]}function fc(e){if(z(e,`role`)!==`assistant`||z(e,`stopReason`)!==`error`)return;let t=z(e,`errorMessage`)?.trim();return sc(`system`,`Model response failed: ${t===void 0||t===``?`The model returned an error.`:t}`)}function pc(e){let t=z(e,`role`);return(t===`user`||t===`assistant`||t===`tool`||t===`system`||t===`bash`||t===`skill`)&&Array.isArray(Nc(e,`parts`))}function mc(e){if(e.length!==1||e[0]?.type!==`text`)return;let t=hc(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 hc(e){let t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;let n=t[4]?.trim();return{name:t[1]??`skill`,location:t[2]??``,content:t[3]??``,...n===void 0||n===``?{}:{userMessage:n}}}function gc(e){let t=z(e,`source`);if(t===`compaction`||t===`branch_summary`)return t}function _c(e){let t=vc(Nc(e,`timestamp`)),n=yc(e);if(!(t===void 0&&n===void 0))return{...t===void 0?{}:{timestamp:t},...n===void 0?{}:{model:n}}}function vc(e){if(typeof e==`number`&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!=`string`||e===``)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function yc(e){if(z(e,`role`)!==`assistant`)return;let t=z(e,`provider`),n=z(e,`model`),r=z(e,`responseModel`);if(!((t===void 0||t===``)&&(n===void 0||n===``)&&(r===void 0||r===``)))return{...t===void 0||t===``?{}:{provider:t},...n===void 0||n===``?{}:{id:n},...r===void 0||r===``?{}:{responseId:r}}}function bc(e){let t=z(e,`command`)??``,n=Pc(e,`excludeFromContext`)===!0?[`excluded from context`,``,`$ ${t}`]:[`$ ${t}`],r=Nc(e,`output`);r!=null&&n.push(``,Ic(r));let i=Nc(e,`exitCode`);i!=null&&n.push(``,`exit ${Ic(i)}`),Pc(e,`cancelled`)===!0&&n.push(``,`cancelled`),Pc(e,`truncated`)===!0&&n.push(``,`output truncated`);let a=z(e,`fullOutputPath`);return a!==void 0&&a!==``&&n.push(``,`full output: ${a}`),{role:`bash`,parts:[{type:`text`,text:n.join(`
|
|
4
4
|
`)}]}}function xc(e){return e===`assistant`?`assistant`:e===`user`?`user`:e===`toolResult`?`tool`:`system`}function Sc(e,t){return typeof e==`string`?e===``?[]:[{type:`text`,text:e}]:Array.isArray(e)?e.flatMap(e=>{let t=z(e,`type`),n=z(e,`text`);if(t===`text`)return n!==void 0&&n!==``?[{type:`text`,text:n}]:[];if(t===`thinking`){let t=z(e,`thinking`)??n;return t!==void 0&&t!==``?[{type:`thinking`,text:t}]:[]}if(t===`toolCall`){let t=z(e,`name`)??`tool`,n=Nc(e,`arguments`),r=z(e,`id`),i=t===`read`?wc(z(n,`path`)):void 0;return i===void 0?[{type:`toolCall`,...r===void 0?{}:{toolCallId:r},toolName:t,summary:Ac(n),...n===void 0?{}:{args:n}}]:[{type:`skillRead`,...i,...r===void 0?{}:{toolCallId:r}}]}if(t===`image`){let t=z(e,`data`),n=z(e,`mimeType`);return t!==void 0&&t!==``&&n!==void 0&&n!==``?[{type:`image`,mimeType:n,data:t}]:[{type:`text`,text:`[image]`}]}return kc(e)}).map(e=>e.type===`text`&&z(t,`role`)===`toolResult`?Cc(e.text,t):e):kc(e)}function Cc(e,t){let n=z(t,`toolCallId`),r=Nc(t,`content`),i=Nc(t,`details`);return{type:`toolResult`,...n===void 0?{}:{toolCallId:n},toolName:z(t,`toolName`)??`tool`,text:e,...r===void 0?{}:{content:r},...i===void 0?{}:{details:i},isError:Pc(t,`isError`)===!0}}function wc(e){if(e===void 0||e===``)return;let t=e.replace(/\\/g,`/`);if(!t.endsWith(`/SKILL.md`)&&t!==`SKILL.md`)return;let n=t.split(`/`).at(-2);if(!(n===void 0||n===``))return{name:n,path:e}}function Tc(e){let t=[],n=new Map;for(let r of e){let e=[],i={...r.entryId===void 0?{}:{entryId:r.entryId},...r.previousAssistantEntryId===void 0?{}:{previousAssistantEntryId:r.previousAssistantEntryId},...r.canFork===void 0?{}:{canFork:r.canFork},...r.source===void 0?{}:{source:r.source},...r.meta===void 0?{}:{meta:r.meta}},a=()=>{e.length!==0&&(t.push({role:r.role,parts:e,...i}),e=[])};for(let o of r.parts){if(o.type===`toolCall`){a();let e=Ec(o),r=t.length;t.push({role:`tool`,parts:[e],...i}),e.toolCallId!==void 0&&n.set(e.toolCallId,{lineIndex:r,partIndex:0});continue}if(o.type===`toolResult`){let e=o.toolCallId===void 0?void 0:n.get(o.toolCallId);if(e!==void 0&&Dc(t,e,o)){n.delete(o.toolCallId??``);continue}}e.push(o)}a()}return t}function Ec(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 Dc(e,t,n){let r=e[t.lineIndex],i=r?.parts[t.partIndex];if(r===void 0||i?.type!==`toolExecution`)return!1;let a=Oc(n.details)??i.preview,o={...i,status:n.isError?`error`:`success`,resultText:n.text,...n.content===void 0?{}:{content:n.content},...n.details===void 0?{}:{details:n.details},...a===void 0?{}:{preview:a}};return e[t.lineIndex]={...r,parts:[...r.parts.slice(0,t.partIndex),o,...r.parts.slice(t.partIndex+1)]},!0}function Oc(e){let t=Nc(e,`preview`);if(!Mc(t))return;let n=z(t,`diff`),r=z(t,`error`),i=Fc(t,`firstChangedLine`);if(!(n===void 0&&r===void 0&&i===void 0))return{...n===void 0?{}:{diff:n},...r===void 0?{}:{error:r},...i===void 0?{}:{firstChangedLine:i}}}function kc(e){return e==null?[]:typeof e==`object`?[{type:`text`,text:Ac(e)}]:[{type:`text`,text:Ic(e)}]}function Ac(e){if(!Mc(e))return Ic(e);let t=z(e,`command`);if(t!==void 0)return t;let n=z(e,`path`);if(n!==void 0)return n;if(typeof e.oldText==`string`&&typeof e.newText==`string`)return`edit text replacement`;let r=e.edits;return Array.isArray(r)?`${String(r.length)} edit${r.length===1?``:`s`}`:Object.entries(e).filter(([,e])=>e!=null).slice(0,3).map(([e,t])=>`${e}: ${jc(t)}`).join(` · `)}function jc(e){return typeof e==`string`?e.length>80?`${e.slice(0,77)}…`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?``:`s`}`:typeof e==`object`&&e?`object`:``}function Mc(e){return typeof e==`object`&&!!e}function Nc(e,t){return Mc(e)?e[t]:void 0}function z(e,t){let n=Nc(e,t);return typeof n==`string`?n:void 0}function Pc(e,t){let n=Nc(e,t);return typeof n==`boolean`?n:void 0}function Fc(e,t){let n=Nc(e,t);return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Ic(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`?String(e):``}var Lc=`pi-webui:prompt-draft:`;function Rc(e){return`${Lc}${e}`}function zc(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function Bc(e,t=zc()){try{return t?.getItem(Rc(e))??``}catch{return``}}function Vc(e,t,n=zc()){try{t?n?.setItem(Rc(e),t):n?.removeItem(Rc(e))}catch{}}function Hc(e,t=zc()){try{t?.removeItem(Rc(e))}catch{}}function Uc(e,t,n=zc()){let r=Bc(e,n);r!==``&&(Vc(t,r,n),Hc(e,n))}function Wc(e,t){return sc(`bash`,`${t===!0?`excluded from context
|
|
@@ -1090,7 +1090,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1090
1090
|
.review-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1091
1091
|
.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; }
|
|
1092
1092
|
footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
|
|
1093
|
-
`]}};B([x({attribute:!1})],im.prototype,`context`,void 0),B([C(`#workspace-upload-input`)],im.prototype,`uploadInput`,void 0),B([S()],im.prototype,`pendingUpload`,void 0),B([S()],im.prototype,`destinationFolder`,void 0),B([S()],im.prototype,`overwrite`,void 0),B([S()],im.prototype,`createDirs`,void 0),B([S()],im.prototype,`formError`,void 0),B([S()],im.prototype,`dragActive`,void 0),im=B([b(`workspace-files-panel`)],im);function am(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function om(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{So(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function sm(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function cm(e){let t=e.selectedFileContent;if(e.selectedFilePath===void 0||e.selectedFilePath===``)return`Select a file.`;if(t===void 0)return`Loading ${e.selectedFilePath}…`;if(t.mediaType!==`image`&&t.binary)return`Binary file: ${t.path} · ${xm(t.size)}`}function lm(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function um(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function dm(e){return e==null?[]:Array.from(e)}function fm(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function pm(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function mm(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function hm(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return ym(e.percent)}}function gm(e){return e.status===`uploading`?e.percent:1}function _m(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return ym(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function vm(e){return e.error===void 0?e.response===void 0?`${e.path} · ${xm(e.loaded)} / ${xm(e.total)}`:`Wrote ${e.response.path}`:e.error}function ym(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function bm(){rm(()=>import(`./CodeViewer-
|
|
1093
|
+
`]}};B([x({attribute:!1})],im.prototype,`context`,void 0),B([C(`#workspace-upload-input`)],im.prototype,`uploadInput`,void 0),B([S()],im.prototype,`pendingUpload`,void 0),B([S()],im.prototype,`destinationFolder`,void 0),B([S()],im.prototype,`overwrite`,void 0),B([S()],im.prototype,`createDirs`,void 0),B([S()],im.prototype,`formError`,void 0),B([S()],im.prototype,`dragActive`,void 0),im=B([b(`workspace-files-panel`)],im);function am(e,t){return Object.values(e).filter(e=>e.projectId===t.projectId&&e.workspaceId===t.workspaceId&&e.machineId===t.machineId).sort((e,t)=>t.startedAt.localeCompare(e.startedAt))}function om(e,t){if(e.length===0)return`Choose at least one file to upload.`;for(let n of e)try{So(t,n.name)}catch(e){return e instanceof Error?e.message:String(e)}}function sm(e){return{destinationFolder:e,createDirs:!0,overwrite:!1}}function cm(e){let t=e.selectedFileContent;if(e.selectedFilePath===void 0||e.selectedFilePath===``)return`Select a file.`;if(t===void 0)return`Loading ${e.selectedFilePath}…`;if(t.mediaType!==`image`&&t.binary)return`Binary file: ${t.path} · ${xm(t.size)}`}function lm(e,t){if(t.length!==0)return e.onStartWorkspaceUpload(t,{destinationFolder:e.workspaceUploadDefaultFolder,createDirs:!0,overwrite:!1,selectUploadedFile:!0})}function um(e){return`${e.machine.id}:${e.workspace.projectId}:${e.workspace.id}`}function dm(e){return e==null?[]:Array.from(e)}function fm(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function pm(e){let t=e.filter(e=>e.status===`uploading`).length;return t===0?`${String(e.length)} recent`:`${String(t)} uploading`}function mm(e){let t=e.files.length,n=t===1?`file`:`files`;switch(e.status){case`completed`:return`Uploaded ${String(t)} ${n}`;case`error`:return`Upload failed for ${String(t)} ${n}`;case`cancelled`:return`Upload cancelled for ${String(t)} ${n}`;case`uploading`:return`Uploading ${String(t)} ${n}`}}function hm(e){switch(e.status){case`completed`:return`Done`;case`error`:return`Failed`;case`cancelled`:return`Cancelled`;case`uploading`:return ym(e.percent)}}function gm(e){return e.status===`uploading`?e.percent:1}function _m(e){switch(e.status){case`pending`:return`Pending`;case`uploading`:return ym(e.percent);case`completed`:return`Done`;case`error`:return`Error`;case`cancelled`:return`Cancelled`}}function vm(e){return e.error===void 0?e.response===void 0?`${e.path} · ${xm(e.loaded)} / ${xm(e.total)}`:`Wrote ${e.response.path}`:e.error}function ym(e){return`${String(Math.round(Math.max(0,Math.min(1,e))*100))}%`}function bm(){rm(()=>import(`./CodeViewer-Bpvsp0pk.js`),__vite__mapDeps([0,1,2,3]),import.meta.url)}function xm(e){if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${String(e)} B`;let t=e/1024;if(t<1024)return`${Sm(t)} KB`;let n=t/1024;return n<1024?`${Sm(n)} MB`:`${Sm(n/1024)} GB`}function Sm(e){return e>=10?String(Math.round(e)):e.toFixed(1)}var Cm=2e3,wm=class extends y{constructor(...e){super(...e),this.loading=!1,this.error=``,this.dynamicMetricsRequest=0,this.dynamicMetricsRefreshInFlight=!1}willUpdate(e){if(!e.has(`context`))return;let t=this.context?.machine.id;if(t===void 0){this.stopDynamicMetricsPolling(),this.machineId=void 0;return}t!==this.machineId&&(this.stopDynamicMetricsPolling(),this.machineId=t,this.loadSystemInfo(t))}async loadSystemInfo(e=this.machineId){if(e!==void 0){this.loading=!0,this.error=``;try{let t=await za.systemInfo(e);this.isCurrentMachine(e)&&(this.systemInfo=t,this.isConnected&&this.startDynamicMetricsPolling())}catch(t){this.isCurrentMachine(e)&&(this.error=t instanceof Error?t.message:String(t))}finally{this.isCurrentMachine(e)&&(this.loading=!1)}}}connectedCallback(){super.connectedCallback(),this.startDynamicMetricsPolling()}disconnectedCallback(){this.stopDynamicMetricsPolling(),super.disconnectedCallback()}startDynamicMetricsPolling(){let e=this.machineId;e===void 0||this.systemInfo===void 0||this.dynamicMetricsTimer!==void 0||(this.dynamicMetricsPollingMachineId=e,this.dynamicMetricsTimer=window.setInterval(()=>{this.refreshDynamicMetrics(e)},Cm))}stopDynamicMetricsPolling(){this.dynamicMetricsTimer!==void 0&&window.clearInterval(this.dynamicMetricsTimer),this.dynamicMetricsTimer=void 0,this.dynamicMetricsPollingMachineId=void 0,this.dynamicMetricsRequest+=1,this.dynamicMetricsRefreshInFlight=!1}async refreshDynamicMetrics(e){if(this.loading||this.error!==``||this.dynamicMetricsRefreshInFlight||this.dynamicMetricsPollingMachineId!==e)return;this.dynamicMetricsRefreshInFlight=!0;let t=++this.dynamicMetricsRequest;try{let n=await za.systemMetrics(e);if(!this.isCurrentDynamicMetricsRequest(e,t))return;this.applyDynamicMetrics(n)}catch{}finally{t===this.dynamicMetricsRequest&&(this.dynamicMetricsRefreshInFlight=!1)}}isCurrentDynamicMetricsRequest(e,t){return t===this.dynamicMetricsRequest&&this.dynamicMetricsPollingMachineId===e&&this.isCurrentMachine(e)}applyDynamicMetrics(e){let t=this.systemInfo;t!==void 0&&(this.systemInfo={...t,memory:e.memory,network:{...t.network,...e.network}})}isCurrentMachine(e){return this.machineId===e&&this.context?.machine.id===e}render(){if(this.loading)return g`<section class="info-panel"><p class="muted">Loading system information…</p></section>`;if(this.error!==``)return g`<section class="info-panel">
|
|
1094
1094
|
<p class="error-text">Failed to load system information: ${this.error}</p>
|
|
1095
1095
|
<button @click=${()=>{this.loadSystemInfo()}}>Retry</button>
|
|
1096
1096
|
</section>`;let e=this.systemInfo;return e===void 0?g`<section class="info-panel"><p class="muted">System information unavailable.</p></section>`:g`<section class="info-panel">
|
|
@@ -1334,7 +1334,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1334
1334
|
<div class="viewer-header"><strong>${e.path??`diff`}</strong><small>${e.staged?`staged`:`unstaged`}${e.truncated?` · truncated`:``}</small></div>
|
|
1335
1335
|
<unified-diff-viewer .diff=${e.diff}></unified-diff-viewer>
|
|
1336
1336
|
</section>
|
|
1337
|
-
`}function Lm(){rm(()=>import(`./UnifiedDiffViewer-
|
|
1337
|
+
`}function Lm(){rm(()=>import(`./UnifiedDiffViewer-iSh_gYQc.js`),[],import.meta.url)}function Rm(){rm(()=>Promise.resolve().then(()=>WD),void 0,import.meta.url)}function zm(e){return g`<workspace-info-panel .context=${e}></workspace-info-panel>`}function Bm(e){let t=Vm(e);return g`
|
|
1338
1338
|
<p class="summary">
|
|
1339
1339
|
<span class="summary-branch">${t.branch}</span>
|
|
1340
1340
|
${t.latestTag===void 0?null:g`<span class="summary-tag" aria-label=${`Latest tag ${t.latestTag}`}>${t.latestTag}</span>`}
|
|
@@ -1384,17 +1384,18 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1384
1384
|
.machine-primary-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
1385
1385
|
.machine-menu-panel button.danger { color: var(--pi-danger); }
|
|
1386
1386
|
.machine-menu-panel button.danger:hover, .machine-menu-panel button.danger:focus { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
1387
|
-
`]}};B([x({attribute:!1})],v_.prototype,`machines`,void 0),B([x({attribute:!1})],v_.prototype,`selected`,void 0),B([x({attribute:!1})],v_.prototype,`statuses`,void 0),B([x({attribute:!1})],v_.prototype,`activities`,void 0),B([x({type:Boolean,reflect:!0})],v_.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],v_.prototype,`collapsed`,void 0),B([x({attribute:!1})],v_.prototype,`onSelect`,void 0),B([x({attribute:!1})],v_.prototype,`onRemove`,void 0),B([x({attribute:!1})],v_.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],v_.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],v_.prototype,`onCancelKeyboardNavigation`,void 0),B([S()],v_.prototype,`openMenuMachineId`,void 0),B([S()],v_.prototype,`menuStyle`,void 0),v_=B([b(`machine-list`)],v_);function y_(e){return e.kind===`remote`}function b_(e){return`machine-menu-${e.replace(/[^a-zA-Z0-9_-]/g,`-`)}`}var V=class extends y{constructor(...e){super(...e),this.projects=[],this.activities={},this.workspacesByProjectId={},this.collapsible=!1,this.collapsed=!1,this.menuStyle=``,this.searchOpen=!1,this.searchQuery=``,this.onDocumentClick=e=>{Qg(e,this.renderRoot)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick,!0)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick,!0),super.disconnectedCallback()}updated(e){e.has(`projects`)&&this.openMenuProjectId!==void 0&&!this.projects.some(e=>e.id===this.openMenuProjectId)&&(this.openMenuProjectId=void 0),e.has(`collapsed`)&&this.collapsed&&(this.openMenuProjectId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,u_(this.renderRoot,{fallbackSelector:`.section-toggle`})}render(){let e=
|
|
1387
|
+
`]}};B([x({attribute:!1})],v_.prototype,`machines`,void 0),B([x({attribute:!1})],v_.prototype,`selected`,void 0),B([x({attribute:!1})],v_.prototype,`statuses`,void 0),B([x({attribute:!1})],v_.prototype,`activities`,void 0),B([x({type:Boolean,reflect:!0})],v_.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],v_.prototype,`collapsed`,void 0),B([x({attribute:!1})],v_.prototype,`onSelect`,void 0),B([x({attribute:!1})],v_.prototype,`onRemove`,void 0),B([x({attribute:!1})],v_.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],v_.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],v_.prototype,`onCancelKeyboardNavigation`,void 0),B([S()],v_.prototype,`openMenuMachineId`,void 0),B([S()],v_.prototype,`menuStyle`,void 0),v_=B([b(`machine-list`)],v_);function y_(e){return e.kind===`remote`}function b_(e){return`machine-menu-${e.replace(/[^a-zA-Z0-9_-]/g,`-`)}`}var x_={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},S_=e=>(...t)=>({_$litDirective$:e,values:t}),C_=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},{I:w_}=ft,T_=e=>e,E_=()=>document.createComment(``),D_=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new w_(r.insertBefore(E_(),i),r.insertBefore(E_(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=T_(e).nextSibling;T_(r).insertBefore(e,i),e=t}}}return n},O_=(e,t,n=e)=>(e._$AI(t,n),e),k_={},A_=(e,t=k_)=>e._$AH=t,j_=e=>e._$AH,M_=e=>{e._$AR(),e._$AA.remove()},N_=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},P_=S_(class extends C_{constructor(e){if(super(e),e.type!==x_.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=j_(e),{values:a,keys:o}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=o,a;let s=this.ut??=[],c=[],l,u,d=0,f=i.length-1,p=0,m=a.length-1;for(;d<=f&&p<=m;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(s[d]===o[p])c[p]=O_(i[d],a[p]),d++,p++;else if(s[f]===o[m])c[m]=O_(i[f],a[m]),f--,m--;else if(s[d]===o[m])c[m]=O_(i[d],a[m]),D_(e,c[m+1],i[d]),d++,m--;else if(s[f]===o[p])c[p]=O_(i[f],a[p]),D_(e,i[d],i[f]),f--,p++;else if(l===void 0&&(l=N_(o,p,m),u=N_(s,d,f)),l.has(s[d]))if(l.has(s[f])){let t=u.get(o[p]),n=t===void 0?null:i[t];if(n===null){let t=D_(e,i[d]);O_(t,a[p]),c[p]=t}else c[p]=O_(n,a[p]),D_(e,i[d],n),i[t]=null;p++}else M_(i[f]),f--;else M_(i[d]),d++;for(;p<=m;){let t=D_(e,c[m+1]);O_(t,a[p]),c[p++]=t}for(;d<=f;){let e=i[d++];e!==null&&M_(e)}return this.ut=o,A_(e,c),Qe}});function F_(e,t){let n=t.trim().toLowerCase();return n===``?[...e]:e.filter(e=>`${e.name} ${e.path}`.toLowerCase().includes(n))}function I_(e,t,n){let r=[],i=[];for(let a of e)(Ns(a,t[a.id]??[],n)===void 0?i:r).push(a);return[...r,...i]}function L_(e,t,n,r){return I_(F_(e,t),n,r)}var V=class extends y{constructor(...e){super(...e),this.projects=[],this.activities={},this.workspacesByProjectId={},this.collapsible=!1,this.collapsed=!1,this.menuStyle=``,this.searchOpen=!1,this.searchQuery=``,this.onDocumentClick=e=>{Qg(e,this.renderRoot)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick,!0)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick,!0),super.disconnectedCallback()}updated(e){if(e.has(`projects`)&&this.openMenuProjectId!==void 0&&!this.projects.some(e=>e.id===this.openMenuProjectId)&&(this.openMenuProjectId=void 0),this.openMenuProjectId!==void 0&&(e.has(`projects`)||e.has(`activities`)||e.has(`workspacesByProjectId`))){let t=e.get(`projects`)??this.projects,n=e.get(`workspacesByProjectId`)??this.workspacesByProjectId,r=e.get(`activities`)??this.activities;R_(this.openMenuProjectId,L_(t,this.searchQuery,n,r),L_(this.projects,this.searchQuery,this.workspacesByProjectId,this.activities))&&(this.openMenuProjectId=void 0)}e.has(`collapsed`)&&this.collapsed&&(this.openMenuProjectId=void 0)}async focusSelectedOrFirst(){return await this.updateComplete,u_(this.renderRoot,{fallbackSelector:`.section-toggle`})}render(){let e=L_(this.projects,this.searchQuery,this.workspacesByProjectId,this.activities);return g`
|
|
1388
1388
|
<section>
|
|
1389
1389
|
<h2>
|
|
1390
1390
|
${this.renderHeading()}
|
|
1391
|
+
${this.renderExpandedBrowserButton()}
|
|
1391
1392
|
${this.collapsed?null:this.renderSearchButton()}
|
|
1392
1393
|
${this.renderAddButton()}
|
|
1393
1394
|
</h2>
|
|
1394
1395
|
${this.collapsed?null:g`
|
|
1395
1396
|
${this.searchOpen?this.renderSearchInput():null}
|
|
1396
1397
|
<div class="list-body">
|
|
1397
|
-
${e.
|
|
1398
|
+
${P_(e,e=>e.id,e=>g`
|
|
1398
1399
|
<div
|
|
1399
1400
|
class=${`action-row ${this.selected?.id===e.id?`selected`:``}`}
|
|
1400
1401
|
tabindex="0"
|
|
@@ -1424,23 +1425,146 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1424
1425
|
<button type="button" class="section-search-button" title=${e} aria-label=${e} aria-expanded=${String(this.searchOpen)} aria-controls="project-search" @click=${e=>{e.stopPropagation(),this.toggleProjectSearch()}}>
|
|
1425
1426
|
${_`<svg class="section-search-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="11" cy="11" r="6"></circle><path d="m16 16 4 4"></path></svg>`}
|
|
1426
1427
|
</button>
|
|
1427
|
-
`}
|
|
1428
|
+
`}renderExpandedBrowserButton(){return g`
|
|
1429
|
+
<button type="button" class="section-expand-button" title="Open expanded project browser" aria-label="Open expanded project browser" @click=${e=>{this.openExpandedBrowser(e)}}>
|
|
1430
|
+
${_`<svg class="section-expand-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 3H3v6M15 3h6v6M21 15v6h-6M9 21H3v-6"></path></svg>`}
|
|
1431
|
+
</button>
|
|
1432
|
+
`}openExpandedBrowser(e){e.stopPropagation();let t=e.currentTarget;this.onOpenExpanded?.(()=>{t instanceof HTMLButtonElement&&t.focus()})}renderSearchInput(){return g`
|
|
1428
1433
|
<div class="project-search">
|
|
1429
1434
|
<input id="project-search" class="project-search-input" type="search" placeholder="Search projects" aria-label="Search projects" .value=${this.searchQuery} @input=${e=>{this.handleSearchInput(e)}}>
|
|
1430
1435
|
</div>
|
|
1431
1436
|
`}renderAddButton(){return g`<button class="section-add-button" title="Add project" aria-label="Add project" @click=${e=>{e.stopPropagation(),this.onAdd?.()}}>+</button>`}toggleProjectSearch(){if(this.searchOpen=!this.searchOpen,!this.searchOpen){this.searchQuery=``;return}this.updateComplete.then(()=>{this.searchOpen&&this.searchInput?.focus()})}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.searchQuery=e.target.value,this.openMenuProjectId=void 0)}renderActivity(e){let t=Ns(e,this.workspacesByProjectId[e.id]??[],this.activities);return i_(t,t===`terminal`?`Project terminal active`:`Project active`)}toggleMenu(e,t){if(this.openMenuProjectId===e){this.openMenuProjectId=void 0;return}this.menuStyle=$g(t,{constrainTo:`viewport`}),this.openMenuProjectId=e}close(e){this.openMenuProjectId=void 0,confirm(`Close ${e.name}?\n\nThis only removes it from PI WEBUI; it will not change the project folder.`)&&this.onClose?.(e)}static{this.styles=[qp,h`
|
|
1432
|
-
.section-search-button { box-sizing: border-box; flex: 0 0 auto; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; }
|
|
1433
|
-
.section-search-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
|
|
1437
|
+
.section-search-button, .section-expand-button { box-sizing: border-box; flex: 0 0 auto; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; }
|
|
1438
|
+
.section-search-icon, .section-expand-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
1434
1439
|
.project-search { flex: 0 0 auto; margin: 0 0 6px; }
|
|
1435
1440
|
.project-search-input { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 6px 8px; font: inherit; }
|
|
1436
1441
|
.project-search-input:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 1px; }
|
|
1437
1442
|
.project-search-empty { margin: 6px 0; color: var(--pi-muted); }
|
|
1438
|
-
`]}};B([x({attribute:!1})],V.prototype,`projects`,void 0),B([x({attribute:!1})],V.prototype,`selected`,void 0),B([x({attribute:!1})],V.prototype,`activities`,void 0),B([x({attribute:!1})],V.prototype,`workspacesByProjectId`,void 0),B([x({type:Boolean,reflect:!0})],V.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],V.prototype,`collapsed`,void 0),B([x({attribute:!1})],V.prototype,`onSelect`,void 0),B([x({attribute:!1})],V.prototype,`onClose`,void 0),B([x({attribute:!1})],V.prototype,`onAdd`,void 0),B([x({attribute:!1})],V.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],V.prototype,`onFocusPreviousSection`,void 0),B([x({attribute:!1})],V.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],V.prototype,`onCancelKeyboardNavigation`,void 0),B([C(`.project-search-input`)],V.prototype,`searchInput`,void 0),B([S()],V.prototype,`openMenuProjectId`,void 0),B([S()],V.prototype,`menuStyle`,void 0),B([S()],V.prototype,`searchOpen`,void 0),B([S()],V.prototype,`searchQuery`,void 0),V=B([b(`project-list`)],V);function
|
|
1443
|
+
`]}};B([x({attribute:!1})],V.prototype,`projects`,void 0),B([x({attribute:!1})],V.prototype,`selected`,void 0),B([x({attribute:!1})],V.prototype,`activities`,void 0),B([x({attribute:!1})],V.prototype,`workspacesByProjectId`,void 0),B([x({type:Boolean,reflect:!0})],V.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],V.prototype,`collapsed`,void 0),B([x({attribute:!1})],V.prototype,`onSelect`,void 0),B([x({attribute:!1})],V.prototype,`onClose`,void 0),B([x({attribute:!1})],V.prototype,`onAdd`,void 0),B([x({attribute:!1})],V.prototype,`onOpenExpanded`,void 0),B([x({attribute:!1})],V.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],V.prototype,`onFocusPreviousSection`,void 0),B([x({attribute:!1})],V.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],V.prototype,`onCancelKeyboardNavigation`,void 0),B([C(`.project-search-input`)],V.prototype,`searchInput`,void 0),B([S()],V.prototype,`openMenuProjectId`,void 0),B([S()],V.prototype,`menuStyle`,void 0),B([S()],V.prototype,`searchOpen`,void 0),B([S()],V.prototype,`searchQuery`,void 0),V=B([b(`project-list`)],V);function R_(e,t,n){return t.findIndex(t=>t.id===e)!==n.findIndex(t=>t.id===e)}var z_=class extends y{constructor(...e){super(...e),this.projects=[],this.activities={},this.workspacesByProjectId={},this.searchQuery=``,this.menuStyle=``,this.onDocumentClick=e=>{this.openMenuProjectId===void 0||Qg(e,this.renderRoot)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick,!0)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick,!0),super.disconnectedCallback()}firstUpdated(){this.searchInput?.focus()}updated(e){if(e.has(`projects`)&&this.openMenuProjectId!==void 0&&!this.projects.some(e=>e.id===this.openMenuProjectId)){this.openMenuProjectId=void 0;return}if(this.openMenuProjectId===void 0||!e.has(`projects`)&&!e.has(`activities`)&&!e.has(`workspacesByProjectId`))return;let t=e.get(`projects`)??this.projects,n=e.get(`activities`)??this.activities,r=e.get(`workspacesByProjectId`)??this.workspacesByProjectId;B_(L_(t,this.searchQuery,r,n),this.visibleProjects)&&(this.openMenuProjectId=void 0)}get visibleProjects(){return L_(this.projects,this.searchQuery,this.workspacesByProjectId,this.activities)}close(){this.openMenuProjectId=void 0,this.onClose?.()}select(e){this.openMenuProjectId=void 0,this.hasProject(e.id)&&this.onSelect?.(e)}render(){return g`
|
|
1444
|
+
<div class="backdrop" @mousedown=${e=>{this.handleBackdropMouseDown(e)}}>
|
|
1445
|
+
<section
|
|
1446
|
+
role="dialog"
|
|
1447
|
+
aria-modal="true"
|
|
1448
|
+
aria-labelledby="project-browser-title"
|
|
1449
|
+
tabindex="-1"
|
|
1450
|
+
@mousedown=${e=>{e.stopPropagation()}}
|
|
1451
|
+
@keydown=${e=>{this.handleDialogKeyDown(e)}}
|
|
1452
|
+
>
|
|
1453
|
+
<header>
|
|
1454
|
+
<h1 id="project-browser-title">Projects</h1>
|
|
1455
|
+
<div class="header-actions">
|
|
1456
|
+
<button class="add-button" type="button" @click=${()=>{this.onAdd?.()}}>Add project</button>
|
|
1457
|
+
<button class="close-button" type="button" title="Close expanded project browser" aria-label="Close expanded project browser" @click=${()=>{this.close()}}>
|
|
1458
|
+
<svg class="close-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 6 12 12M18 6 6 18"></path></svg>
|
|
1459
|
+
</button>
|
|
1460
|
+
</div>
|
|
1461
|
+
</header>
|
|
1462
|
+
<div class="dialog-body">
|
|
1463
|
+
<label class="search-label" for="project-browser-search">Search projects</label>
|
|
1464
|
+
<input
|
|
1465
|
+
id="project-browser-search"
|
|
1466
|
+
class="project-browser-search"
|
|
1467
|
+
type="search"
|
|
1468
|
+
placeholder="Search projects"
|
|
1469
|
+
.value=${this.searchQuery}
|
|
1470
|
+
@input=${e=>{this.handleSearchInput(e)}}
|
|
1471
|
+
>
|
|
1472
|
+
<div class="result-area" @scroll=${()=>{this.openMenuProjectId=void 0}}>
|
|
1473
|
+
${this.renderResults()}
|
|
1474
|
+
</div>
|
|
1475
|
+
</div>
|
|
1476
|
+
</section>
|
|
1477
|
+
</div>
|
|
1478
|
+
`}renderResults(){if(this.projects.length===0)return g`
|
|
1479
|
+
<div class="empty-state">
|
|
1480
|
+
<p>No projects are open.</p>
|
|
1481
|
+
<button class="add-empty-button" type="button" @click=${()=>{this.onAdd?.()}}>Add project</button>
|
|
1482
|
+
</div>
|
|
1483
|
+
`;let e=this.visibleProjects;return e.length===0?g`<p class="empty-state">No matching projects.</p>`:g`
|
|
1484
|
+
<div class="project-list">
|
|
1485
|
+
${P_(e,e=>e.id,e=>g`
|
|
1486
|
+
<div
|
|
1487
|
+
class=${`project-row action-row ${this.selected?.id===e.id?`selected`:``}`}
|
|
1488
|
+
tabindex="0"
|
|
1489
|
+
title=${e.path}
|
|
1490
|
+
@click=${t=>{c_(t,()=>{this.select(e)})}}
|
|
1491
|
+
@keydown=${t=>{this.handleProjectKeydown(t,e)}}
|
|
1492
|
+
>
|
|
1493
|
+
<div class="project-main">
|
|
1494
|
+
<span class="project-name">${e.name}</span>
|
|
1495
|
+
<span class="project-path">${e.path}</span>
|
|
1496
|
+
${this.renderActivity(e)}
|
|
1497
|
+
</div>
|
|
1498
|
+
<div class="action-menu">
|
|
1499
|
+
<button class="action-menu-toggle" type="button" title="Project actions" aria-label=${`Actions for ${e.name}`} @click=${t=>{t.stopPropagation(),this.toggleMenu(e.id,t.currentTarget)}}>
|
|
1500
|
+
<svg class="action-menu-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor"><circle cx="5" cy="12" r="1.5"></circle><circle cx="12" cy="12" r="1.5"></circle><circle cx="19" cy="12" r="1.5"></circle></svg>
|
|
1501
|
+
</button>
|
|
1502
|
+
${this.openMenuProjectId===e.id?g`
|
|
1503
|
+
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
1504
|
+
<button type="button" title="Close project" @click=${()=>{this.closeProject(e)}}>Close</button>
|
|
1505
|
+
</div>
|
|
1506
|
+
`:null}
|
|
1507
|
+
</div>
|
|
1508
|
+
</div>
|
|
1509
|
+
`)}
|
|
1510
|
+
</div>
|
|
1511
|
+
`}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.searchQuery=e.target.value,this.openMenuProjectId=void 0)}handleProjectKeydown(e,t){l_(e,{activate:()=>{this.select(t)}})}handleBackdropMouseDown(e){e.target===e.currentTarget&&(e.preventDefault(),this.close())}handleDialogKeyDown(e){if(e.key===`Tab`){this.trapTabFocus(e);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())}trapTabFocus(e){let t=[...this.renderRoot.querySelectorAll(`button:not(:disabled), input:not(:disabled), textarea:not(:disabled), [tabindex='0']`)];if(t.length===0){e.preventDefault(),this.renderRoot.querySelector(`section[role='dialog']`)?.focus();return}let n=this.shadowRoot?.activeElement,r=t.findIndex(e=>e===n),i=!e.shiftKey&&r===t.length-1,a=e.shiftKey&&r<=0;!i&&!a||(e.preventDefault(),(e.shiftKey?t.at(-1):t[0])?.focus())}toggleMenu(e,t){if(!this.hasProject(e)){this.openMenuProjectId=void 0;return}if(this.openMenuProjectId===e){this.openMenuProjectId=void 0;return}this.menuStyle=$g(t,{constrainTo:`viewport`}),this.openMenuProjectId=e}closeProject(e){this.openMenuProjectId=void 0,this.hasProject(e.id)&&confirm(`Close ${e.name}?\n\nThis only removes it from PI WEBUI; it will not change the project folder.`)&&this.onCloseProject?.(e)}renderActivity(e){let t=Ns(e,this.workspacesByProjectId[e.id]??[],this.activities);return i_(t,t===`terminal`?`Project terminal active`:`Project active`)}hasProject(e){return this.projects.some(t=>t.id===e)}static{this.styles=h`
|
|
1512
|
+
:host { position: fixed; inset: 0; z-index: 60; display: block; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1513
|
+
* { box-sizing: border-box; }
|
|
1514
|
+
.backdrop { width: 100%; height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--pi-overlay); }
|
|
1515
|
+
section[role="dialog"] { width: min(960px, 100%); height: min(760px, 100%); min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 64px var(--pi-shadow-strong); }
|
|
1516
|
+
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--pi-border); }
|
|
1517
|
+
h1, p { margin: 0; }
|
|
1518
|
+
h1 { font-size: 20px; line-height: 1.25; }
|
|
1519
|
+
.header-actions { display: flex; align-items: center; gap: 8px; }
|
|
1520
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 8px 11px; font: inherit; cursor: pointer; }
|
|
1521
|
+
button:hover { background: var(--pi-surface-hover); }
|
|
1522
|
+
button:focus-visible, input:focus-visible, .project-row:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
1523
|
+
.add-button { border-color: var(--pi-accent); background: var(--pi-accent); color: var(--pi-bg); font-weight: 700; }
|
|
1524
|
+
.add-button:hover { background: var(--pi-accent); filter: brightness(1.08); }
|
|
1525
|
+
.close-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--pi-muted); }
|
|
1526
|
+
.close-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
|
|
1527
|
+
.close-button:hover { color: var(--pi-text); }
|
|
1528
|
+
.dialog-body { min-height: 0; display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 7px; padding: 16px; }
|
|
1529
|
+
.search-label { font-weight: 700; }
|
|
1530
|
+
.project-browser-search { width: 100%; min-width: 0; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 8px 10px; font: inherit; }
|
|
1531
|
+
.result-area { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
|
|
1532
|
+
.project-list { display: grid; gap: 8px; }
|
|
1533
|
+
.project-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; cursor: pointer; }
|
|
1534
|
+
.project-main { position: relative; min-width: 0; display: grid; gap: 3px; border: 1px solid var(--pi-border); border-radius: 8px 0 0 8px; background: var(--pi-surface); padding: 9px 28px 9px 11px; }
|
|
1535
|
+
.project-row:hover .project-main { background: var(--pi-surface-hover); }
|
|
1536
|
+
.project-row.selected .project-main, .project-row.selected .action-menu-toggle { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
1537
|
+
.project-name { min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
|
|
1538
|
+
.project-path { min-width: 0; white-space: normal; overflow-wrap: anywhere; color: var(--pi-muted); font-size: 12px; line-height: 1.35; }
|
|
1539
|
+
.action-activity { position: absolute; top: 6px; right: 7px; display: grid; place-items: center; width: 10px; height: 10px; }
|
|
1540
|
+
.action-activity .activity-indicator { margin: 0; }
|
|
1541
|
+
.activity-indicator { display: inline-block; width: 7px; height: 7px; background: var(--pi-success); animation: pulse 1s ease-in-out infinite; }
|
|
1542
|
+
.activity-indicator.session { border-radius: 50%; background: var(--pi-success); }
|
|
1543
|
+
.activity-indicator.terminal { border-radius: 2px; background: var(--pi-accent); }
|
|
1544
|
+
.action-menu { position: relative; }
|
|
1545
|
+
.action-menu-toggle { display: grid; place-items: center; width: 36px; height: 100%; min-height: 100%; border-left: 0; border-radius: 0 8px 8px 0; padding: 0; color: var(--pi-muted); }
|
|
1546
|
+
.action-menu-icon { width: 18px; height: 18px; }
|
|
1547
|
+
.action-menu-toggle:hover { color: var(--pi-text); }
|
|
1548
|
+
.action-menu-panel { position: fixed; z-index: 70; min-width: min(120px, calc(100vw - 16px)); max-width: 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; }
|
|
1549
|
+
.action-menu-panel button { display: block; width: 100%; border: 0; background: transparent; text-align: left; white-space: normal; overflow-wrap: anywhere; }
|
|
1550
|
+
.action-menu-panel button:hover { background: var(--pi-selection-bg); }
|
|
1551
|
+
.empty-state { display: grid; gap: 10px; justify-items: start; margin: 0; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-muted); padding: 14px; }
|
|
1552
|
+
.add-empty-button { color: var(--pi-text); }
|
|
1553
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
1554
|
+
|
|
1555
|
+
@media (max-width: 760px) {
|
|
1556
|
+
.backdrop { padding: 0; }
|
|
1557
|
+
section[role="dialog"] { width: 100%; height: 100%; border: 0; border-radius: 0; }
|
|
1558
|
+
header, .dialog-body { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
|
|
1559
|
+
header { padding-top: max(12px, env(safe-area-inset-top)); }
|
|
1560
|
+
.dialog-body { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
|
|
1561
|
+
}
|
|
1562
|
+
`}};B([x({attribute:!1})],z_.prototype,`projects`,void 0),B([x({attribute:!1})],z_.prototype,`selected`,void 0),B([x({attribute:!1})],z_.prototype,`activities`,void 0),B([x({attribute:!1})],z_.prototype,`workspacesByProjectId`,void 0),B([x({attribute:!1})],z_.prototype,`onSelect`,void 0),B([x({attribute:!1})],z_.prototype,`onCloseProject`,void 0),B([x({attribute:!1})],z_.prototype,`onAdd`,void 0),B([x({attribute:!1})],z_.prototype,`onClose`,void 0),B([S()],z_.prototype,`searchQuery`,void 0),B([S()],z_.prototype,`openMenuProjectId`,void 0),B([S()],z_.prototype,`menuStyle`,void 0),B([C(`.project-browser-search`)],z_.prototype,`searchInput`,void 0),z_=B([b(`project-browser-dialog`)],z_);function B_(e,t){return e.length!==t.length||e.some((e,n)=>e.id!==t[n]?.id)}function V_(e=[]){return e.map((e,t)=>g`${t===0?null:g`<span class="workspace-label-separator">·</span>`}${H_(e)}`)}function H_(e){if(e.type===`render`)return g`<span class="workspace-label-render">${e.render()}</span>`;if(e.type===`link`&&U_(e.href)){let t=e.target??`_blank`,n=t===`_blank`?`noopener noreferrer`:void 0;return g`<a class="workspace-label-item workspace-label-link" href=${e.href} title=${e.title??e.text} target=${t} rel=${n??void 0}>${e.text}</a>`}return g`<span class="workspace-label-item" title=${e.title??e.text}>${e.text}</span>`}function U_(e){let t=e.trim().toLowerCase();return t!==``&&!t.startsWith(`javascript:`)&&!t.startsWith(`data:`)}var W_=class extends y{constructor(...e){super(...e),this.workspaces=[],this.collapsible=!1,this.collapsed=!1,this.workspaceLabelItems=()=>[],this.activities={},this.deletingWorkspaceIds=[],this.menuStyle=``,this.onDocumentClick=e=>{Qg(e,this.renderRoot)||(this.openMenuWorkspaceId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick,!0)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick,!0),super.disconnectedCallback()}updated(e){e.has(`workspaces`)&&this.openMenuWorkspaceId!==void 0&&!this.workspaces.some(e=>e.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,u_(this.renderRoot,{fallbackSelector:`.section-toggle`})}render(){return g`
|
|
1439
1563
|
<section>
|
|
1440
1564
|
<h2>${this.renderHeading()}</h2>
|
|
1441
1565
|
${this.collapsed?null:g`
|
|
1442
1566
|
<div class="list-body">
|
|
1443
|
-
${this.workspaces.map(e=>{let t=
|
|
1567
|
+
${this.workspaces.map(e=>{let t=G_(e),n=this.workspaceLabelItems(e);return g`
|
|
1444
1568
|
<div
|
|
1445
1569
|
class=${`action-row workspace-row ${this.selected?.id===e.id?`selected`:``}`}
|
|
1446
1570
|
tabindex="0"
|
|
@@ -1464,11 +1588,11 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1464
1588
|
</span>
|
|
1465
1589
|
${t.length===0?null:g`
|
|
1466
1590
|
<small class="workspace-secondary">
|
|
1467
|
-
<span class="workspace-label">${
|
|
1591
|
+
<span class="workspace-label">${V_(t)}</span>
|
|
1468
1592
|
</small>
|
|
1469
1593
|
`}
|
|
1470
1594
|
${this.renderActivity(n)}
|
|
1471
|
-
`}renderWorkspaceMenu(e,t,n){let r=this.openMenuWorkspaceId===n.id,i=
|
|
1595
|
+
`}renderWorkspaceMenu(e,t,n){let r=this.openMenuWorkspaceId===n.id,i=q_(n.id);return g`
|
|
1472
1596
|
<div class="action-menu">
|
|
1473
1597
|
<button
|
|
1474
1598
|
class="action-menu-toggle"
|
|
@@ -1485,7 +1609,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1485
1609
|
</div>
|
|
1486
1610
|
`:null}
|
|
1487
1611
|
</div>
|
|
1488
|
-
`}renderWorkspaceActions(e){if(!
|
|
1612
|
+
`}renderWorkspaceActions(e){if(!K_(e))return;let t=this.isDeleting(e);return g`
|
|
1489
1613
|
<div class="workspace-menu-actions">
|
|
1490
1614
|
<button class="danger" title=${t?`Workspace deletion in progress`:`Delete workspace`} ?disabled=${t} @click=${()=>{this.delete(e)}}>${t?`Deleting…`:`Delete workspace`}</button>
|
|
1491
1615
|
</div>
|
|
@@ -1502,11 +1626,11 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1502
1626
|
${t.length===0?null:g`
|
|
1503
1627
|
<div class="workspace-detail-row">
|
|
1504
1628
|
<dt>Details</dt>
|
|
1505
|
-
<dd><span class="workspace-label">${
|
|
1629
|
+
<dd><span class="workspace-label">${V_(t)}</span></dd>
|
|
1506
1630
|
</div>
|
|
1507
1631
|
`}
|
|
1508
1632
|
</dl>
|
|
1509
|
-
`}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=$g(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}l_(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`})}static{this.styles=qp}};B([x({attribute:!1})],
|
|
1633
|
+
`}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=$g(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}l_(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`})}static{this.styles=qp}};B([x({attribute:!1})],W_.prototype,`workspaces`,void 0),B([x({attribute:!1})],W_.prototype,`selected`,void 0),B([x({type:Boolean,reflect:!0})],W_.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],W_.prototype,`collapsed`,void 0),B([x({attribute:!1})],W_.prototype,`workspaceLabelItems`,void 0),B([x({attribute:!1})],W_.prototype,`activities`,void 0),B([x({attribute:!1})],W_.prototype,`deletingWorkspaceIds`,void 0),B([x({attribute:!1})],W_.prototype,`onSelect`,void 0),B([x({attribute:!1})],W_.prototype,`onDelete`,void 0),B([x({attribute:!1})],W_.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],W_.prototype,`onFocusPreviousSection`,void 0),B([x({attribute:!1})],W_.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],W_.prototype,`onCancelKeyboardNavigation`,void 0),B([S()],W_.prototype,`openMenuWorkspaceId`,void 0),B([S()],W_.prototype,`menuStyle`,void 0),W_=B([b(`workspace-list`)],W_);function G_(e){return`${e.branch??e.label}${e.isMain?` · main`:``}`}function K_(e){return e.isGitWorktree&&!e.isMain}function q_(e){return`workspace-menu-${e.replace(/[^a-zA-Z0-9_-]/g,`-`)}`}function J_(e){return e.slice(-8)}function Y_(e){return e.name!==void 0&&e.name!==``?e.name:e.firstMessage===``?J_(e.id):e.firstMessage}var H=class extends y{constructor(...e){super(...e),this.sessions=[],this.projectSessions=[],this.workspaces=[],this.statuses={},this.activities={},this.sending={},this.unreadSessionIds=new Set,this.startingCount=0,this.canStart=!1,this.canDeleteArchived=!1,this.canReload=!1,this.canCleanup=!1,this.authoritativeSessionPersistence=!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.renameInputValue=``,this.foldedSessionPaths=new Set,this.onDocumentClick=e=>{Qg(e,this.renderRoot)||(this.openMenuSessionId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.onDocumentClick,!0)}disconnectedCallback(){document.removeEventListener(`click`,this.onDocumentClick,!0),super.disconnectedCallback()}updated(e){e.has(`sessions`)&&(this.openMenuSessionId!==void 0&&!this.sessions.some(e=>e.id===this.openMenuSessionId)&&(this.openMenuSessionId=void 0),this.renamingSessionId!==void 0&&!this.sessions.some(e=>e.id===this.renamingSessionId)&&this.cancelSessionRename(),this.sessions.some(e=>e.archived===!0)||(this.archivedExpanded=!1),this.pruneSelectedSessionIds()),e.has(`currentWorkspacePath`)?this.foldedSessionPaths=new Set:(e.has(`sessions`)||e.has(`projectSessions`))&&this.pruneFoldedSessionPaths(),e.has(`collapsed`)&&this.collapsed&&(this.openMenuSessionId=void 0,this.cancelSessionRename());let 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,u_(this.renderRoot,{fallbackSelector:`.section-toggle, h2 button:not([disabled])`})}render(){let e=this.currentWorkspacePath,t=new Set(this.workspaces.map(e=>e.path));e!==void 0&&t.add(e);let n=nv([...this.sessions,...this.projectSessions.filter(t=>t.cwd!==e)],{...e===void 0?{}:{currentWorkspacePath:e,knownWorkspacePaths:t},foldedSessionPaths:this.foldedSessionPaths}),r=n.reduce((e,t)=>(t.depth===0?e.push([t]):e.at(-1)?.push(t),e),[]),i=new Set(n.map(e=>e.session.path)),a=n.filter(e=>!e.external).map(e=>e.session).filter(e=>Q_(e)===`current`),o=rv(this.sessions.filter(e=>e.archived===!0&&!i.has(e.path))),s=ev(this.sessions),c=X_(a,this.unreadSessionIds,{statuses:this.statuses,activities:this.activities,sending:this.sending});return g`
|
|
1510
1634
|
<section>
|
|
1511
1635
|
${this.renderHeading(n.length+o.length,a,c)}
|
|
1512
1636
|
${this.collapsed?null:g`
|
|
@@ -1532,7 +1656,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1532
1656
|
${this.renderCleanupButton()}
|
|
1533
1657
|
${this.renderStartButton()}
|
|
1534
1658
|
</h2>
|
|
1535
|
-
`;let r=this.selected===void 0?`No session selected`:
|
|
1659
|
+
`;let r=this.selected===void 0?`No session selected`:Y_(this.selected),i=this.selected?.path??r;return g`
|
|
1536
1660
|
<h2>
|
|
1537
1661
|
<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?g`<small class="section-selected" dir="auto" title=${i}>${r}</small>`:null}</span></button>
|
|
1538
1662
|
${this.renderCurrentSelectionButton(t)}
|
|
@@ -1571,7 +1695,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1571
1695
|
<button @click=${()=>{this.closeSelection(`archived`)}}>Done</button>
|
|
1572
1696
|
${this.canDeleteArchived?null:g`<small class="capability-hint">${this.archivedDeleteUnavailableMessage}</small>`}
|
|
1573
1697
|
</div>
|
|
1574
|
-
`}renderSession(e,t,n){let{session:r}=e,i=Math.min(e.depth,2),a=!e.external&&
|
|
1698
|
+
`}renderSession(e,t,n){let{session:r}=e,i=Math.min(e.depth,2),a=!e.external&&Q_(r)===n,o=this.selectionScopes.has(n)&&!e.external,s=o&&a,c=s&&this.selectedSessionIds.has(r.id),l=this.statuses[r.id],u=this.activities[r.id],d=tv(r,l,u,this.sending[r.id]===!0,this.unreadSessionIds.has(r.id)),f=this.sessionPersistenceOptions(),p=mu(r,l,f),m=hu(r,l,f),ee=p&&this.canReload,te=e.external?this.workspaces.find(e=>e.path===r.cwd):void 0,ne=te===void 0?void 0:te.branch??te.label;return g`
|
|
1575
1699
|
<div
|
|
1576
1700
|
class="action-row ${this.selected?.id===r.id?`selected`:``} ${c?`bulk-selected`:``} ${r.archived===!0?`archived`:``} ${e.external?`external-session`:``} ${o?`selecting`:``} ${d===`unread`?`unread`:``}"
|
|
1577
1701
|
style=${`--depth:${String(i)}`}
|
|
@@ -1582,9 +1706,9 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1582
1706
|
@keydown=${t=>{this.handleSessionKeydown(t,r,n,e.external)}}
|
|
1583
1707
|
>
|
|
1584
1708
|
<div class="action-main ${o?`selecting`:``}">
|
|
1585
|
-
${s?g`<input class="session-checkbox" type="checkbox" aria-label=${`Select ${
|
|
1709
|
+
${s?g`<input class="session-checkbox" type="checkbox" aria-label=${`Select ${Y_(r)}`} .checked=${c} @click=${e=>{e.stopPropagation()}} @change=${()=>{this.toggleSelected(r.id)}}>`:null}
|
|
1586
1710
|
<span class="action-name-line">
|
|
1587
|
-
${this.renamingSessionId===r.id?this.renderSessionRenameInput(r):g`${this.renderSessionGroupToggle(e)}<span class="action-name" dir="auto">${e.depth>0?g`<span class="tree-marker">↳</span>`:null}${!e.external&&r.pinned===!0?g`<button class="pinned-star" type="button" title="Click to unpin session" aria-label="Unpin session" @click=${e=>{e.stopPropagation(),this.onUnpin?.(r)}}>★</button> `:null}${
|
|
1711
|
+
${this.renamingSessionId===r.id?this.renderSessionRenameInput(r):g`${this.renderSessionGroupToggle(e)}<span class="action-name" dir="auto">${e.depth>0?g`<span class="tree-marker">↳</span>`:null}${!e.external&&r.pinned===!0?g`<button class="pinned-star" type="button" title="Click to unpin session" aria-label="Unpin session" @click=${e=>{e.stopPropagation(),this.onUnpin?.(r)}}>★</button> `:null}${Y_(r)}${e.depth>2?g` <span class="badge">depth ${e.depth}</span>`:null}${ne===void 0?null:g` <span class="badge external-workspace" title=${`Open ${ne} workspace`}>${ne} ↗</span>`}${e.hasMissingParent?g` <span class="badge">parent unavailable</span>`:null}</span>`}
|
|
1588
1712
|
</span><small>${this.renderSessionMetaPrefix(r,l,u)}${String(r.messageCount)} messages</small>
|
|
1589
1713
|
${this.renderActivity(d)}
|
|
1590
1714
|
</div>
|
|
@@ -1610,7 +1734,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1610
1734
|
</div>
|
|
1611
1735
|
`}
|
|
1612
1736
|
</div>
|
|
1613
|
-
`}startSessionRename(e,t,n,r){r||o_(e)||t.archived===!0||this.selectionScopes.has(n)||hu(t,this.statuses[t.id],this.sessionPersistenceOptions())||(this.onRenameStart?.(t),e.preventDefault(),e.stopPropagation(),this.renamingSessionId=t.id,this.renameInputValue=t.name??
|
|
1737
|
+
`}startSessionRename(e,t,n,r){r||o_(e)||t.archived===!0||this.selectionScopes.has(n)||hu(t,this.statuses[t.id],this.sessionPersistenceOptions())||(this.onRenameStart?.(t),e.preventDefault(),e.stopPropagation(),this.renamingSessionId=t.id,this.renameInputValue=t.name??Y_(t),this.updateComplete.then(()=>{if(this.renamingSessionId!==t.id)return;let e=this.renderRoot.querySelector(`.session-name-input`);e?.focus(),e?.select()}))}renderSessionRenameInput(e){return g`
|
|
1614
1738
|
<input
|
|
1615
1739
|
class="session-name-input"
|
|
1616
1740
|
aria-label="Rename session"
|
|
@@ -1619,7 +1743,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1619
1743
|
@click=${e=>{e.stopPropagation()}}
|
|
1620
1744
|
@blur=${t=>{this.commitSessionRename(e,this.sessionRenameInputValue(t))}}
|
|
1621
1745
|
>
|
|
1622
|
-
`}handleSessionRenameKeydown(e,t){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.cancelSessionRename();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),this.commitSessionRename(t,this.sessionRenameInputValue(e)))}sessionRenameInputValue(e){return
|
|
1746
|
+
`}handleSessionRenameKeydown(e,t){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.cancelSessionRename();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),this.commitSessionRename(t,this.sessionRenameInputValue(e)))}sessionRenameInputValue(e){return Z_(e.currentTarget)?e.currentTarget.value:this.renameInputValue}commitSessionRename(e,t=this.renameInputValue){if(this.renamingSessionId!==e.id)return;let n=t.trim(),r=e.name??Y_(e);this.cancelSessionRename(),!(n===``||n===r)&&this.onRename?.(e,n)}cancelSessionRename(){this.renamingSessionId=void 0,this.renameInputValue=``}renderSessionGroupToggle(e){if(!e.hasChildren)return null;let t=this.foldedSessionPaths.has(e.session.path),n=t?`Expand`:`Collapse`;return g`<button class="session-group-toggle" type="button" title=${`${n} ${Y_(e.session)}`} aria-label=${`${n} ${Y_(e.session)}`} aria-expanded=${String(!t)} @click=${t=>{t.stopPropagation(),this.toggleSessionGroup(e.session.path)}}>${t?`▸`:`▾`}</button>`}toggleSessionGroup(e){let t=new Set(this.foldedSessionPaths);t.has(e)?t.delete(e):t.add(e),this.foldedSessionPaths=t}handleSessionKeydown(e,t,n,r){l_(e,{activate:()=>{this.activateSessionRow(t,n,r)},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,n){if(!n&&this.selectionScopes.has(t)&&Q_(e)===t){this.toggleSelected(e.id);return}this.onSelect?.(e)}confirmArchiveWithDescendants(e,t){let n=t===1?`descendant session`:`descendant sessions`;confirm(`Archive “${Y_(e)}” and ${String(t)} ${n}?`)&&this.onArchiveWithDescendants?.(e)}confirmDeleteArchived(e){this.canDeleteArchived&&confirm(`Permanently delete archived session “${Y_(e)}”? This cannot be undone.`)&&this.onDeleteArchived?.(e)}confirmDeleteSelectedArchived(){if(!this.canDeleteArchived)return;let e=this.selectedSessions(`archived`);if(e.length===0)return;let t=e.length===1?`archived session`:`archived sessions`;confirm(`Permanently delete ${String(e.length)} selected ${t}? This cannot be undone.`)&&(this.selectedSessionIds=$_(this.selectedSessionIds,e.map(e=>e.id)),this.onDeleteArchivedMany?.(e))}archiveSelectedCurrent(){let e=this.selectedSessions(`current`).filter(e=>mu(e,this.statuses[e.id],this.sessionPersistenceOptions()));this.selectedSessionIds=$_(this.selectedSessionIds,e.map(e=>e.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]);let n=t.length===1?t[0]:void 0;n!==void 0&&(this.selectedSessionIds=new Set([...this.selectedSessionIds,n.id]))}closeSelection(e){this.selectionScopes=new Set([...this.selectionScopes].filter(t=>t!==e)),this.clearSelection(e)}clearSelection(e){let t=this.sessions.filter(t=>Q_(t)===e).map(e=>e.id);this.selectedSessionIds=$_(this.selectedSessionIds,t)}toggleSelected(e){let t=new Set(this.selectedSessionIds);t.has(e)?t.delete(e):t.add(e),this.selectedSessionIds=t}toggleVisibleSelection(e,t){let n=new Set(this.selectedSessionIds);for(let r of e)t?n.add(r.id):n.delete(r.id);this.selectedSessionIds=n}selectedSessions(e){return this.sessions.filter(t=>this.selectedSessionIds.has(t.id)&&Q_(t)===e)}pruneFoldedSessionPaths(){let e=new Set([...this.sessions,...this.projectSessions].map(e=>e.path)),t=new Set([...this.foldedSessionPaths].filter(t=>e.has(t)));t.size!==this.foldedSessionPaths.size&&(this.foldedSessionPaths=t)}pruneSelectedSessionIds(){let e=new Set(this.sessions.map(e=>e.id)),t=new Set([...this.selectedSessionIds].filter(t=>e.has(t)));t.size!==this.selectedSessionIds.size&&(this.selectedSessionIds=t),this.selectionScopes.has(`archived`)&&!this.sessions.some(e=>e.archived===!0)&&this.closeSelection(`archived`),this.selectionScopes.has(`current`)&&!this.sessions.some(e=>e.archived!==!0)&&this.closeSelection(`current`)}toggleMenu(e,t){if(this.openMenuSessionId===e){this.openMenuSessionId=void 0;return}this.menuStyle=$g(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,t,n){return hu(e,t,this.sessionPersistenceOptions())?n?.phase===`active`?`creating · `:n?.phase===`error`?`error · `:`new · `:e.archived===!0?`read-only · `:``}sessionPersistenceOptions(){return{authoritative:this.authoritativeSessionPersistence}}renderActivity(e){return i_(e,e===`sending`?`Sending message`:e===`unread`?`Unread session activity`:`Session active`)}static{this.styles=[qp,h`
|
|
1623
1747
|
h2 { min-height: 30px; }
|
|
1624
1748
|
h2 > .section-count { flex: 0 0 auto; display: inline; color: var(--pi-muted); font-size: inherit; }
|
|
1625
1749
|
h2 > .section-unread-count { flex: 0 0 auto; display: inline; color: var(--pi-accent); font-size: inherit; text-transform: none; }
|
|
@@ -1659,7 +1783,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1659
1783
|
.pinned-star { flex: 0 0 auto; border: 0; background: transparent; color: #d4a017; padding: 0; font: inherit; font-size: 14px; line-height: 1; }
|
|
1660
1784
|
.pinned-star:hover { border-radius: 4px; background: var(--pi-surface); box-shadow: 0 0 0 1px var(--pi-border); transform: scale(1.25); }
|
|
1661
1785
|
.pinned-star:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; border-radius: 2px; }
|
|
1662
|
-
`]}};B([x({attribute:!1})],H.prototype,`sessions`,void 0),B([x({attribute:!1})],H.prototype,`projectSessions`,void 0),B([x({type:String})],H.prototype,`currentWorkspacePath`,void 0),B([x({attribute:!1})],H.prototype,`workspaces`,void 0),B([x({attribute:!1})],H.prototype,`statuses`,void 0),B([x({attribute:!1})],H.prototype,`activities`,void 0),B([x({attribute:!1})],H.prototype,`sending`,void 0),B([x({attribute:!1})],H.prototype,`unreadSessionIds`,void 0),B([x({attribute:!1})],H.prototype,`selected`,void 0),B([x({type:Number})],H.prototype,`startingCount`,void 0),B([x({type:Boolean})],H.prototype,`canStart`,void 0),B([x({type:Boolean})],H.prototype,`canDeleteArchived`,void 0),B([x({type:Boolean})],H.prototype,`canReload`,void 0),B([x({type:Boolean})],H.prototype,`canCleanup`,void 0),B([x({type:Boolean})],H.prototype,`authoritativeSessionPersistence`,void 0),B([x({type:String})],H.prototype,`archivedDeleteUnavailableMessage`,void 0),B([x({type:String})],H.prototype,`cleanupUnavailableMessage`,void 0),B([x({type:Boolean,reflect:!0})],H.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],H.prototype,`collapsed`,void 0),B([x({attribute:!1})],H.prototype,`onSelect`,void 0),B([x({attribute:!1})],H.prototype,`onRenameStart`,void 0),B([x({attribute:!1})],H.prototype,`onRename`,void 0),B([x({attribute:!1})],H.prototype,`onStart`,void 0),B([x({attribute:!1})],H.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],H.prototype,`onArchivedCollapsed`,void 0),B([x({attribute:!1})],H.prototype,`onFocusPreviousSection`,void 0),B([x({attribute:!1})],H.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],H.prototype,`onCancelKeyboardNavigation`,void 0),B([x({attribute:!1})],H.prototype,`onArchive`,void 0),B([x({attribute:!1})],H.prototype,`onArchiveWithDescendants`,void 0),B([x({attribute:!1})],H.prototype,`onArchiveMany`,void 0),B([x({attribute:!1})],H.prototype,`onRestore`,void 0),B([x({attribute:!1})],H.prototype,`onDelete`,void 0),B([x({attribute:!1})],H.prototype,`onDeleteArchived`,void 0),B([x({attribute:!1})],H.prototype,`onDeleteArchivedMany`,void 0),B([x({attribute:!1})],H.prototype,`onDetachParent`,void 0),B([x({attribute:!1})],H.prototype,`onReload`,void 0),B([x({attribute:!1})],H.prototype,`onPin`,void 0),B([x({attribute:!1})],H.prototype,`onUnpin`,void 0),B([x({attribute:!1})],H.prototype,`onCleanup`,void 0),B([S()],H.prototype,`openMenuSessionId`,void 0),B([S()],H.prototype,`menuStyle`,void 0),B([S()],H.prototype,`archivedExpanded`,void 0),B([S()],H.prototype,`selectionScopes`,void 0),B([S()],H.prototype,`selectedSessionIds`,void 0),B([S()],H.prototype,`renamingSessionId`,void 0),B([S()],H.prototype,`renameInputValue`,void 0),B([S()],H.prototype,`foldedSessionPaths`,void 0),H=B([b(`session-list`)],H);function
|
|
1786
|
+
`]}};B([x({attribute:!1})],H.prototype,`sessions`,void 0),B([x({attribute:!1})],H.prototype,`projectSessions`,void 0),B([x({type:String})],H.prototype,`currentWorkspacePath`,void 0),B([x({attribute:!1})],H.prototype,`workspaces`,void 0),B([x({attribute:!1})],H.prototype,`statuses`,void 0),B([x({attribute:!1})],H.prototype,`activities`,void 0),B([x({attribute:!1})],H.prototype,`sending`,void 0),B([x({attribute:!1})],H.prototype,`unreadSessionIds`,void 0),B([x({attribute:!1})],H.prototype,`selected`,void 0),B([x({type:Number})],H.prototype,`startingCount`,void 0),B([x({type:Boolean})],H.prototype,`canStart`,void 0),B([x({type:Boolean})],H.prototype,`canDeleteArchived`,void 0),B([x({type:Boolean})],H.prototype,`canReload`,void 0),B([x({type:Boolean})],H.prototype,`canCleanup`,void 0),B([x({type:Boolean})],H.prototype,`authoritativeSessionPersistence`,void 0),B([x({type:String})],H.prototype,`archivedDeleteUnavailableMessage`,void 0),B([x({type:String})],H.prototype,`cleanupUnavailableMessage`,void 0),B([x({type:Boolean,reflect:!0})],H.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],H.prototype,`collapsed`,void 0),B([x({attribute:!1})],H.prototype,`onSelect`,void 0),B([x({attribute:!1})],H.prototype,`onRenameStart`,void 0),B([x({attribute:!1})],H.prototype,`onRename`,void 0),B([x({attribute:!1})],H.prototype,`onStart`,void 0),B([x({attribute:!1})],H.prototype,`onToggleCollapsed`,void 0),B([x({attribute:!1})],H.prototype,`onArchivedCollapsed`,void 0),B([x({attribute:!1})],H.prototype,`onFocusPreviousSection`,void 0),B([x({attribute:!1})],H.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],H.prototype,`onCancelKeyboardNavigation`,void 0),B([x({attribute:!1})],H.prototype,`onArchive`,void 0),B([x({attribute:!1})],H.prototype,`onArchiveWithDescendants`,void 0),B([x({attribute:!1})],H.prototype,`onArchiveMany`,void 0),B([x({attribute:!1})],H.prototype,`onRestore`,void 0),B([x({attribute:!1})],H.prototype,`onDelete`,void 0),B([x({attribute:!1})],H.prototype,`onDeleteArchived`,void 0),B([x({attribute:!1})],H.prototype,`onDeleteArchivedMany`,void 0),B([x({attribute:!1})],H.prototype,`onDetachParent`,void 0),B([x({attribute:!1})],H.prototype,`onReload`,void 0),B([x({attribute:!1})],H.prototype,`onPin`,void 0),B([x({attribute:!1})],H.prototype,`onUnpin`,void 0),B([x({attribute:!1})],H.prototype,`onCleanup`,void 0),B([S()],H.prototype,`openMenuSessionId`,void 0),B([S()],H.prototype,`menuStyle`,void 0),B([S()],H.prototype,`archivedExpanded`,void 0),B([S()],H.prototype,`selectionScopes`,void 0),B([S()],H.prototype,`selectedSessionIds`,void 0),B([S()],H.prototype,`renamingSessionId`,void 0),B([S()],H.prototype,`renameInputValue`,void 0),B([S()],H.prototype,`foldedSessionPaths`,void 0),H=B([b(`session-list`)],H);function X_(e,t,n={}){return e.filter(e=>tv(e,n.statuses?.[e.id],n.activities?.[e.id],n.sending?.[e.id]===!0,t.has(e.id))===`unread`).length}function Z_(e){return e!==null&&`value`in e&&typeof e.value==`string`}function Q_(e){return e.archived===!0?`archived`:`current`}function $_(e,t){let n=new Set(t);return new Set([...e].filter(e=>!n.has(e)))}function ev(e){let t=new Map;for(let n of e){if(n.parentSessionPath===void 0)continue;let e=t.get(n.parentSessionPath)??[];e.push(n),t.set(n.parentSessionPath,e)}let n=(e,r)=>{if(r.has(e.path))return 0;let i=new Set(r);i.add(e.path);let a=0;for(let r of t.get(e.path)??[])i.has(r.path)||(r.archived!==!0&&(a+=1),a+=n(r,i));return a};return new Map(e.map(e=>[e.id,n(e,new Set)]))}function tv(e,t,n,r,i=!1){if(!(Xs(e)||e.archived===!0))return r?`sending`:Vo(t,n)?`session`:i?`unread`:void 0}function nv(e,t={}){let n=e.filter(e=>t.knownWorkspacePaths===void 0||e.cwd===t.currentWorkspacePath||t.knownWorkspacePaths.has(e.cwd)),r=new Map(n.map(e=>[e.path,e])),i=iv(n,r),a=ov(av(n.filter(e=>t.currentWorkspacePath===void 0?e.archived!==!0:e.cwd===t.currentWorkspacePath).map(e=>e.path),r,i),r);return rv(n.filter(e=>a.has(e.path)),t)}function rv(e,t={}){let n=new Map(e.map(e=>[e.path,e])),r=iv(e,n),i=e.filter(e=>{let t=e.parentSessionPath;return t===void 0||!n.has(t)});i.sort(sv);let a=[],o=(e,i,s)=>{if(s.has(e.path))return;let c=e.parentSessionPath,l=r.get(e.path)??[];if(a.push({session:e,depth:i,hasMissingParent:c!==void 0&&!n.has(c),external:t.currentWorkspacePath!==void 0&&e.cwd!==t.currentWorkspacePath,hasChildren:l.length>0}),t.foldedSessionPaths?.has(e.path)===!0)return;let u=new Set(s);u.add(e.path),l.sort(sv);for(let e of l)o(e,i+1,u)};for(let e of i)o(e,0,new Set);return a}function iv(e,t){let n=new Map;for(let r of e){let e=r.parentSessionPath;if(e===void 0||!t.has(e))continue;let i=n.get(e)??[];i.push(r),n.set(e,i)}return n}function av(e,t,n){let r=new Set,i=[...e];for(;i.length>0;){let e=i.pop();if(e===void 0||r.has(e))continue;let a=t.get(e);if(a!==void 0){r.add(e),a.parentSessionPath!==void 0&&i.push(a.parentSessionPath);for(let t of n.get(e)??[])i.push(t.path)}}return r}function ov(e,t){let n=new Set;for(let r of e){let i=t.get(r);if(i?.archived===!0)continue;n.add(r);let a=i?.parentSessionPath,o=new Set([r]);for(;a!==void 0&&e.has(a)&&!o.has(a);){o.add(a);let e=t.get(a);if(e===void 0)break;n.add(a),a=e.parentSessionPath}}return n}function sv(e,t){let n=e.pinned===!0,r=t.pinned===!0;return n&&!r?-1:!n&&r?1:0}var cv=class extends y{constructor(...e){super(...e),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.runningForce=!1,this.draft={...jf},this.formError=``}willUpdate(e){e.has(`preview`)&&(this.selectedProjectCwds=this.preview?.projects.map(e=>e.cwd))}render(){let e=Mf(this.draft),t=this.selectedPreview(),n=Pf({canCleanup:this.canCleanup,draft:this.draft,preview:t,previewRequest:this.previewRequest,loading:this.loading,running:this.running}),r=n?`Run cleanup`:t!==void 0&&!Ff(t)?`Select at least one project to run cleanup`:`Preview cleanup before running it`;return g`
|
|
1663
1787
|
<div class="backdrop" @mousedown=${()=>{this.onClose?.()}}>
|
|
1664
1788
|
<section role="dialog" aria-modal="true" aria-label="Clean up sessions" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
1665
1789
|
<header>
|
|
@@ -1688,15 +1812,15 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1688
1812
|
`}renderForm(e){let t=this.loading||this.running,n=Mf(this.draft),r=this.preview!==void 0&&n.ok&&Nf(n.request)!==Nf(this.previewRequest)&&Ff(this.preview);return g`
|
|
1689
1813
|
<fieldset ?disabled=${t}>
|
|
1690
1814
|
<label class="toggle-row">
|
|
1691
|
-
<input type="checkbox" .checked=${this.draft.archiveIdleEnabled} @change=${e=>{this.updateDraft({archiveIdleEnabled:
|
|
1815
|
+
<input type="checkbox" .checked=${this.draft.archiveIdleEnabled} @change=${e=>{this.updateDraft({archiveIdleEnabled:lv(e)})}}>
|
|
1692
1816
|
<span>Archive non-archived sessions idle for more than</span>
|
|
1693
|
-
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.archiveIdleDays} ?disabled=${t||!this.draft.archiveIdleEnabled} @input=${e=>{this.updateDraft({archiveIdleDays:
|
|
1817
|
+
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.archiveIdleDays} ?disabled=${t||!this.draft.archiveIdleEnabled} @input=${e=>{this.updateDraft({archiveIdleDays:uv(e)})}}>
|
|
1694
1818
|
<span>days</span>
|
|
1695
1819
|
</label>
|
|
1696
1820
|
<label class="toggle-row delete-row">
|
|
1697
|
-
<input type="checkbox" .checked=${this.draft.deleteArchivedEnabled} @change=${e=>{this.updateDraft({deleteArchivedEnabled:
|
|
1821
|
+
<input type="checkbox" .checked=${this.draft.deleteArchivedEnabled} @change=${e=>{this.updateDraft({deleteArchivedEnabled:lv(e)})}}>
|
|
1698
1822
|
<span>Delete archived sessions archived for more than</span>
|
|
1699
|
-
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.deleteArchivedDays} ?disabled=${t||!this.draft.deleteArchivedEnabled} @input=${e=>{this.updateDraft({deleteArchivedDays:
|
|
1823
|
+
<input class="days" type="number" min="0" step="1" inputmode="numeric" .value=${this.draft.deleteArchivedDays} ?disabled=${t||!this.draft.deleteArchivedEnabled} @input=${e=>{this.updateDraft({deleteArchivedDays:uv(e)})}}>
|
|
1700
1824
|
<span>days</span>
|
|
1701
1825
|
</label>
|
|
1702
1826
|
</fieldset>
|
|
@@ -1733,7 +1857,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1733
1857
|
${t.length===0?g`<p class="hint" role="status">Select at least one project to run cleanup.</p>`:null}
|
|
1734
1858
|
`}renderProjectRow(e,t){return g`
|
|
1735
1859
|
<tr class=${t?``:`unselected`}>
|
|
1736
|
-
<td class="select-cell"><input type="checkbox" aria-label=${`Clean up ${e.cwd}`} .checked=${t} ?disabled=${this.running} @change=${t=>{this.setProjectSelected(e.cwd,
|
|
1860
|
+
<td class="select-cell"><input type="checkbox" aria-label=${`Clean up ${e.cwd}`} .checked=${t} ?disabled=${this.running} @change=${t=>{this.setProjectSelected(e.cwd,lv(t))}}></td>
|
|
1737
1861
|
<th title=${e.cwd} dir="auto">${e.cwd}</th>
|
|
1738
1862
|
<td>${e.archiveCount}</td>
|
|
1739
1863
|
<td>${e.deleteCount}</td>
|
|
@@ -1800,7 +1924,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1800
1924
|
table { min-width: 560px; }
|
|
1801
1925
|
thead th:first-child, td.select-cell { width: 58px; }
|
|
1802
1926
|
}
|
|
1803
|
-
`}};B([x({type:Boolean})],
|
|
1927
|
+
`}};B([x({type:Boolean})],cv.prototype,`canCleanup`,void 0),B([x({type:String})],cv.prototype,`unavailableMessage`,void 0),B([x({attribute:!1})],cv.prototype,`preview`,void 0),B([x({attribute:!1})],cv.prototype,`previewRequest`,void 0),B([x({attribute:!1})],cv.prototype,`result`,void 0),B([x({type:Boolean})],cv.prototype,`loading`,void 0),B([x({type:Boolean})],cv.prototype,`running`,void 0),B([x({type:String})],cv.prototype,`error`,void 0),B([x({attribute:!1})],cv.prototype,`onPreview`,void 0),B([x({attribute:!1})],cv.prototype,`onRun`,void 0),B([x({attribute:!1})],cv.prototype,`onForceCleanup`,void 0),B([x({attribute:!1})],cv.prototype,`onClose`,void 0),B([x({attribute:!1})],cv.prototype,`forceCleanupResult`,void 0),B([x({type:Boolean})],cv.prototype,`runningForce`,void 0),B([S()],cv.prototype,`draft`,void 0),B([S()],cv.prototype,`formError`,void 0),B([S()],cv.prototype,`selectedProjectCwds`,void 0),cv=B([b(`session-cleanup-dialog`)],cv);function lv(e){return e.target instanceof HTMLInputElement&&e.target.checked}function uv(e){return e.target instanceof HTMLInputElement?e.target.value:``}var dv=class extends y{constructor(...e){super(...e),this.machineId=`local`}render(){let e=this.session,t=e===void 0?void 0:bt(Da(e,this.machineId)),n=e===void 0?``:fv(e);return g`
|
|
1804
1928
|
<div class="backdrop" @mousedown=${e=>{e.target===e.currentTarget&&this.close()}}>
|
|
1805
1929
|
<section class="history-window" role="dialog" aria-modal="true" aria-labelledby="session-history-window-title" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
1806
1930
|
<header>
|
|
@@ -1810,7 +1934,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1810
1934
|
${e===void 0?null:g`<span class="session-label" title=${n}>${n}</span>`}
|
|
1811
1935
|
</div>
|
|
1812
1936
|
<button class="icon-button" type="button" title="Close full history" aria-label="Close full history" @click=${()=>{this.close()}}>
|
|
1813
|
-
${
|
|
1937
|
+
${pv()}
|
|
1814
1938
|
</button>
|
|
1815
1939
|
</header>
|
|
1816
1940
|
<div class="history-body">
|
|
@@ -1847,11 +1971,11 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1847
1971
|
header, footer { padding: 12px; }
|
|
1848
1972
|
.session-label { max-width: 68vw; }
|
|
1849
1973
|
}
|
|
1850
|
-
`}};B([x({attribute:!1})],
|
|
1974
|
+
`}};B([x({attribute:!1})],dv.prototype,`session`,void 0),B([x({type:String})],dv.prototype,`machineId`,void 0),B([x({attribute:!1})],dv.prototype,`onClose`,void 0),dv=B([b(`session-history-window`)],dv);function fv(e){let t=e.name?.trim();if(t!==void 0&&t!==``)return t;let n=e.firstMessage.trim();return n===``?e.id:n}function pv(){return _`
|
|
1851
1975
|
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1852
1976
|
<path d="M6 6l12 12M18 6 6 18"></path>
|
|
1853
1977
|
</svg>
|
|
1854
|
-
`}function
|
|
1978
|
+
`}function mv(e){let t=new Map,n=[];for(let r of e.nodes)t.has(r.id)||(t.set(r.id,r),n.push(r.id));let r=bv(t,n),i=new Map;for(let e of n)i.set(e,[]);let a=[];for(let e of n){let t=r.get(e)??null;if(t===null){a.push(e);continue}i.get(t)?.push(e)}let o=new Map,s=new Map,c=new Set,l=[...a].reverse().map(e=>({id:e,depth:0,branchDepth:0}));for(;l.length>0;){let e=l.pop();if(e===void 0||c.has(e.id))continue;c.add(e.id),o.set(e.id,e.depth),s.set(e.id,e.branchDepth);let t=i.get(e.id)??[],n=e.branchDepth+ +(t.length>1);for(let r=t.length-1;r>=0;--r){let i=t[r];i!==void 0&&l.push({id:i,depth:e.depth+1,branchDepth:n})}}for(let e of n)c.has(e)||(a.push(e),r.set(e,null),o.set(e,0),s.set(e,0));let u=new Map;for(let[e,t]of i)u.set(e,t);let d=e.activeLeafId!==null&&t.has(e.activeLeafId)?e.activeLeafId:null;return{nodesById:t,orderedIds:n,rootIds:a,parentById:r,childrenById:u,depthById:o,branchDepthById:s,activePathIds:d===null?new Set:xv(d,r),activeLeafId:d}}function hv(e,t){let n=[],r=new Set,i=[...e.rootIds].reverse();for(;i.length>0;){let a=i.pop();if(a===void 0||r.has(a))continue;let o=e.nodesById.get(a);if(o===void 0)continue;r.add(a);let s=e.childrenById.get(a)??[];if(n.push({node:o,depth:e.depthById.get(a)??0,branchDepth:e.branchDepthById.get(a)??0,parentId:e.parentById.get(a)??null,childIds:s,activePath:e.activePathIds.has(a),activeLeaf:e.activeLeafId===a}),!t.has(a))for(let e=s.length-1;e>=0;--e){let t=s[e];t!==void 0&&i.push(t)}}return n}function gv(e){return e.activeLeafId===null?e.orderedIds.at(-1):e.activeLeafId}function _v(e,t,n){let r=hv(e,t.foldedIds).map(e=>e.node.id),i=Sv(r,t.selectedId),a=i===void 0?-1:r.indexOf(i),o=()=>({...t,selectedId:i,handled:!1}),s=e=>({...t,selectedId:e,handled:!0});switch(n){case`ArrowUp`:return s(a>0?r[a-1]:i);case`ArrowDown`:return s(a>=0&&a<r.length-1?r[a+1]:i);case`Home`:return s(r[0]);case`End`:return s(r.at(-1));case`ArrowLeft`:if(i===void 0)return s(void 0);if((e.childrenById.get(i)??[]).length>0&&!t.foldedIds.has(i)){let e=new Set(t.foldedIds);return e.add(i),{selectedId:i,foldedIds:e,handled:!0}}return s(e.parentById.get(i)??i);case`ArrowRight`:{if(i===void 0)return s(void 0);let n=e.childrenById.get(i)??[];if(n.length===0)return s(i);if(t.foldedIds.has(i)){let e=new Set(t.foldedIds);return e.delete(i),{selectedId:i,foldedIds:e,handled:!0}}return s(n[0])}case`Enter`:return{...t,selectedId:i,handled:!0,...i===void 0?{}:{action:`confirm`}};case`Escape`:return{...t,selectedId:i,handled:!0,action:`cancel`};default:return o()}}function vv(e,t,n){if((e.childrenById.get(n)??[]).length===0)return{...t,selectedId:n};let r=new Set(t.foldedIds);return r.has(n)?r.delete(n):r.add(n),{selectedId:n,foldedIds:r}}function yv(e,t){return e===`none`||e==="default"?{ok:!0,choice:{mode:e}}:t.trim()===``?{ok:!1,error:`Enter custom summary focus instructions.`}:t.length>1e4?{ok:!1,error:`Custom summary focus must be ${String(kt)} characters or fewer.`}:{ok:!0,choice:{mode:`custom`,instructions:t.trim()}}}function bv(e,t){let n=new Map;for(let r of t){let t=e.get(r)?.parentId??null;n.set(r,t!==null&&t!==r&&e.has(t)?t:null)}let r=new Map;for(let e of t){if(r.has(e))continue;let t=[],i=e;for(;i!==null&&!r.has(i);)r.set(i,`visiting`),t.push(i),i=n.get(i)??null;if(i!==null&&r.get(i)===`visiting`){let e=t.at(-1);e!==void 0&&n.set(e,null)}for(let e of t)r.set(e,`visited`)}return n}function xv(e,t){let n=new Set,r=e;for(;r!==null&&!n.has(r);)n.add(r),r=t.get(r)??null;return n}function Sv(e,t){return t!==void 0&&e.includes(t)?t:e.at(-1)}var Cv={nodes:[],activeLeafId:null,activePathIds:[]},wv=8,Tv=class extends y{constructor(...e){super(...e),this.tree=Cv,this.foldedIds=new Set,this.step=`tree`,this.summaryMode=`none`,this.customInstructions=``,this.busy=!1,this.aborting=!1,this.error=``,this.statusMessage=``,this.model=mv(Cv),this.operationGeneration=0}willUpdate(e){e.has(`tree`)&&this.resetTree()}updated(){let e=this.pendingFocus;e!==void 0&&(this.pendingFocus=void 0,e===`tree`?this.focusSelectedTreeItem():e===`custom`?this.renderRoot.querySelector(`#session-tree-custom-focus`)?.focus():this.renderRoot.querySelector(`input[name='session-tree-summary']:checked`)?.focus())}render(){return g`
|
|
1855
1979
|
<div class="backdrop" @mousedown=${e=>{this.handleBackdropMouseDown(e)}}>
|
|
1856
1980
|
<section
|
|
1857
1981
|
role="dialog"
|
|
@@ -1873,7 +1997,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1873
1997
|
${this.renderFooter()}
|
|
1874
1998
|
</section>
|
|
1875
1999
|
</div>
|
|
1876
|
-
`}renderTreeStep(){let e=
|
|
2000
|
+
`}renderTreeStep(){let e=hv(this.model,this.foldedIds);return g`
|
|
1877
2001
|
<div class="body tree-step">
|
|
1878
2002
|
<div class="tree-intro">
|
|
1879
2003
|
<p>Select where conversation context should continue. All retained branches stay in this session file.</p>
|
|
@@ -1892,7 +2016,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1892
2016
|
</div>
|
|
1893
2017
|
`}
|
|
1894
2018
|
</div>
|
|
1895
|
-
`}renderTreeRow(e){let t=e.node.id===this.selectedId,n=e.childIds.length>0&&!this.foldedIds.has(e.node.id),r=[`tree-row`,t?`selected`:``,e.activePath?`active-path`:``,e.activeLeaf?`active-leaf`:``,
|
|
2019
|
+
`}renderTreeRow(e){let t=e.node.id===this.selectedId,n=e.childIds.length>0&&!this.foldedIds.has(e.node.id),r=[`tree-row`,t?`selected`:``,e.activePath?`active-path`:``,e.activeLeaf?`active-leaf`:``,kv(e.node.kind)?`bookkeeping`:``].filter(e=>e!==``).join(` `),i=Ev(e.branchDepth);return g`
|
|
1896
2020
|
<div
|
|
1897
2021
|
class=${r}
|
|
1898
2022
|
style=${`--tree-indent: ${String(i*16)}px; --tree-indent-mobile: ${String(i*12)}px;`}
|
|
@@ -1913,7 +2037,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1913
2037
|
@click=${t=>{this.toggleNode(e.node.id,t)}}
|
|
1914
2038
|
>${e.childIds.length===0?`·`:n?`▾`:`▸`}</span>
|
|
1915
2039
|
<span class="metadata">
|
|
1916
|
-
<span class="kind">${
|
|
2040
|
+
<span class="kind">${Ov(e.node.kind)}</span>
|
|
1917
2041
|
<span class="badges">
|
|
1918
2042
|
${e.activePath&&!e.activeLeaf?g`<span class="badge path">Active path</span>`:null}
|
|
1919
2043
|
${e.activeLeaf?g`<span class="badge leaf">Active leaf</span>`:null}
|
|
@@ -1925,7 +2049,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1925
2049
|
${e.node.timestamp===void 0?null:g`<time datetime=${e.node.timestamp}>${e.node.timestamp}</time>`}
|
|
1926
2050
|
</span>
|
|
1927
2051
|
</div>
|
|
1928
|
-
`}renderConfirmationStep(){let e=this.selectedId===void 0?void 0:this.model.nodesById.get(this.selectedId),t=
|
|
2052
|
+
`}renderConfirmationStep(){let e=this.selectedId===void 0?void 0:this.model.nodesById.get(this.selectedId),t=yv(this.summaryMode,this.customInstructions);return g`
|
|
1929
2053
|
<div class="body confirmation-step">
|
|
1930
2054
|
<div class="confirmation-card">
|
|
1931
2055
|
<div>
|
|
@@ -1934,9 +2058,9 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1934
2058
|
</div>
|
|
1935
2059
|
${e===void 0?g`<div class="empty">The selected history entry is no longer available.</div>`:g`
|
|
1936
2060
|
<div class="selected-entry">
|
|
1937
|
-
<span class="kind">${
|
|
2061
|
+
<span class="kind">${Ov(e.kind)}</span>
|
|
1938
2062
|
<strong dir="auto">${e.summary}</strong>
|
|
1939
|
-
${
|
|
2063
|
+
${Dv(e.kind)?g`<p>This message’s text will return to the prompt editor for optional editing and resubmission.</p>`:g`<p>The prompt editor will be empty after navigating to this entry.</p>`}
|
|
1940
2064
|
</div>
|
|
1941
2065
|
`}
|
|
1942
2066
|
<fieldset ?disabled=${this.busy}>
|
|
@@ -1993,7 +2117,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
1993
2117
|
${this.busy?e?`Summarizing…`:`Navigating…`:e?`Summarize and navigate`:`Navigate`}
|
|
1994
2118
|
</button>
|
|
1995
2119
|
</footer>
|
|
1996
|
-
`}resetTree(){this.operationGeneration+=1,this.model=
|
|
2120
|
+
`}resetTree(){this.operationGeneration+=1,this.model=mv(this.tree),this.selectedId=gv(this.model),this.foldedIds=new Set,this.step=`tree`,this.summaryMode=`none`,this.customInstructions=``,this.busy=!1,this.aborting=!1,this.error=``,this.statusMessage=``,this.pendingFocus=`tree`}selectNode(e){this.model.nodesById.has(e)&&(this.selectedId=e,this.error=``,this.statusMessage=``,this.pendingFocus=`tree`)}toggleNode(e,t){t.preventDefault(),t.stopPropagation();let n=vv(this.model,{selectedId:this.selectedId,foldedIds:this.foldedIds},e);this.selectedId=n.selectedId,this.foldedIds=n.foldedIds,this.error=``,this.statusMessage=``,this.pendingFocus=`tree`}handleTreeKeyDown(e){let t=_v(this.model,{selectedId:this.selectedId,foldedIds:this.foldedIds},e.key);if(t.handled){if(e.preventDefault(),e.stopPropagation(),t.action===`cancel`){this.onCancel?.();return}if(t.action===`confirm`){this.continueToConfirmation();return}this.selectedId=t.selectedId,this.foldedIds=t.foldedIds,this.pendingFocus=`tree`}}continueToConfirmation(){this.selectedId===void 0||!this.model.nodesById.has(this.selectedId)||(yv(this.summaryMode,this.customInstructions).ok||(this.summaryMode=`none`,this.customInstructions=``),this.step=`confirm`,this.error=``,this.statusMessage=``,this.pendingFocus=`summary`)}returnToTree(){this.busy||(this.step=`tree`,this.error=``,this.statusMessage=``,this.pendingFocus=`tree`)}selectSummaryMode(e){this.busy||(this.summaryMode=e,this.error=``,this.statusMessage=``,this.pendingFocus=e===`custom`?`custom`:`summary`)}handleCustomInstructionsInput(e){e.currentTarget instanceof HTMLTextAreaElement&&(this.customInstructions=e.currentTarget.value,this.error=``,this.statusMessage=``)}async submitNavigation(){if(this.busy||this.selectedId===void 0)return;let e=yv(this.summaryMode,this.customInstructions);if(!e.ok){this.error=``,this.statusMessage=``,this.pendingFocus=`custom`,this.requestUpdate();return}let t=this.onNavigate;if(t===void 0){this.error=`Session tree navigation is unavailable. Close and reopen /tree, then try again.`;return}let n=this.selectedId,r=++this.operationGeneration;this.busy=!0,this.aborting=!1,this.error=``,this.statusMessage=``;try{let i=await t(n,e.choice);if(r!==this.operationGeneration||(this.busy=!1,this.aborting=!1,!i.cancelled))return;this.step=`tree`,this.statusMessage=i.aborted===!0?`Summarization cancelled. Your selected history entry is unchanged.`:`Navigation cancelled. Your selected history entry is unchanged.`,this.pendingFocus=`tree`}catch(e){if(r!==this.operationGeneration)return;this.busy=!1,this.aborting=!1,this.statusMessage=``,this.error=`Could not navigate session history: ${Av(e)}`}}async abortNavigation(){if(!this.busy||this.summaryMode===`none`||this.aborting)return;let e=this.onAbort;if(e===void 0){this.error=`Summarization cannot be cancelled from this client.`;return}let t=this.operationGeneration;this.aborting=!0,this.error=``,this.statusMessage=`Cancelling summarization…`;try{await e()}catch(e){if(t!==this.operationGeneration)return;this.aborting=!1,this.statusMessage=``,this.error=`Could not cancel summarization: ${Av(e)}`}}handleBackdropMouseDown(e){e.target===e.currentTarget&&!this.busy&&this.onCancel?.()}handleDialogKeyDown(e){if(e.key===`Tab`){this.trapTabFocus(e);return}if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),this.busy){this.summaryMode!==`none`&&this.abortNavigation();return}this.step===`confirm`?this.returnToTree():this.onCancel?.()}}trapTabFocus(e){let t=[...this.renderRoot.querySelectorAll(`button:not(:disabled), input:not(:disabled), textarea:not(:disabled), [tabindex='0']`)];if(t.length===0){e.preventDefault(),this.renderRoot.querySelector(`section[role='dialog']`)?.focus();return}let n=this.shadowRoot?.activeElement,r=t.findIndex(e=>e===n),i=!e.shiftKey&&r===t.length-1,a=e.shiftKey&&r<=0;!i&&!a||(e.preventDefault(),(e.shiftKey?t.at(-1):t[0])?.focus())}focusSelectedTreeItem(){let e=this.selectedId;if(e===void 0){this.renderRoot.querySelector(`.close-button`)?.focus();return}let t=this.renderRoot.querySelectorAll(`[data-tree-node-id]`);for(let n of t)if(n.dataset.treeNodeId===e){n.focus(),n.scrollIntoView({block:`nearest`});return}}static{this.styles=h`
|
|
1997
2121
|
:host { position: fixed; inset: 0; z-index: 40; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1998
2122
|
* { box-sizing: border-box; }
|
|
1999
2123
|
.backdrop { width: 100%; height: 100dvh; background: var(--pi-overlay); overflow: hidden; }
|
|
@@ -2086,7 +2210,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
2086
2210
|
.custom-focus, .validation-error { margin-inline-start: 0; }
|
|
2087
2211
|
footer { flex-wrap: wrap; }
|
|
2088
2212
|
}
|
|
2089
|
-
`}};B([x({attribute:!1})],ov.prototype,`tree`,void 0),B([x({attribute:!1})],ov.prototype,`onNavigate`,void 0),B([x({attribute:!1})],ov.prototype,`onAbort`,void 0),B([x({attribute:!1})],ov.prototype,`onCancel`,void 0),B([S()],ov.prototype,`selectedId`,void 0),B([S()],ov.prototype,`foldedIds`,void 0),B([S()],ov.prototype,`step`,void 0),B([S()],ov.prototype,`summaryMode`,void 0),B([S()],ov.prototype,`customInstructions`,void 0),B([S()],ov.prototype,`busy`,void 0),B([S()],ov.prototype,`aborting`,void 0),B([S()],ov.prototype,`error`,void 0),B([S()],ov.prototype,`statusMessage`,void 0),ov=B([b(`session-tree-navigator`)],ov);function sv(e){return Math.min(Math.max(0,e),av)}function cv(e){return e===`user`||e===`custom-message`}function lv(e){switch(e){case`user`:return`User`;case`assistant`:return`Assistant`;case`tool-result`:return`Tool result`;case`bash`:return`Shell`;case`custom-message`:return`Custom message`;case`compaction`:return`Compaction`;case`branch-summary`:return`Branch summary`;case`model-change`:return`Model`;case`thinking-level-change`:return`Thinking`;case`session-info`:return`Session info`;case`label`:return`Label`;case`custom`:return`Custom`;case`other`:return`Other`}}function uv(e){return e===`model-change`||e===`thinking-level-change`||e===`session-info`||e===`label`||e===`custom`||e===`other`}function dv(e){return e instanceof Error?e.message:String(e)}var fv={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},pv=e=>(...t)=>({_$litDirective$:e,values:t}),mv=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},{I:hv}=ft,gv=e=>e,_v=()=>document.createComment(``),vv=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new hv(r.insertBefore(_v(),i),r.insertBefore(_v(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=gv(e).nextSibling;gv(r).insertBefore(e,i),e=t}}}return n},yv=(e,t,n=e)=>(e._$AI(t,n),e),bv={},xv=(e,t=bv)=>e._$AH=t,Sv=e=>e._$AH,Cv=e=>{e._$AR(),e._$AA.remove()},wv=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},Tv=pv(class extends mv{constructor(e){if(super(e),e.type!==fv.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=Sv(e),{values:a,keys:o}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=o,a;let s=this.ut??=[],c=[],l,u,d=0,f=i.length-1,p=0,m=a.length-1;for(;d<=f&&p<=m;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(s[d]===o[p])c[p]=yv(i[d],a[p]),d++,p++;else if(s[f]===o[m])c[m]=yv(i[f],a[m]),f--,m--;else if(s[d]===o[m])c[m]=yv(i[d],a[m]),vv(e,c[m+1],i[d]),d++,m--;else if(s[f]===o[p])c[p]=yv(i[f],a[p]),vv(e,i[d],i[f]),f--,p++;else if(l===void 0&&(l=wv(o,p,m),u=wv(s,d,f)),l.has(s[d]))if(l.has(s[f])){let t=u.get(o[p]),n=t===void 0?null:i[t];if(n===null){let t=vv(e,i[d]);yv(t,a[p]),c[p]=t}else c[p]=yv(n,a[p]),vv(e,i[d],n),i[t]=null;p++}else Cv(i[f]),f--;else Cv(i[d]),d++;for(;p<=m;){let t=vv(e,c[m+1]);yv(t,a[p]),c[p++]=t}for(;d<=f;){let e=i[d++];e!==null&&Cv(e)}return this.ut=o,xv(e,c),Qe}}),Ev=`pi-webui:chat-groups:`,Dv={read(e){try{if(typeof localStorage>`u`)return;let t=localStorage.getItem(kv(e));return t===null||t===``?void 0:Av(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(kv(e),JSON.stringify(t))}catch{}}},Ov=class{constructor(e=Dv){this.storage=e,this.sessionId=``,this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(e){if(this.sessionId===e)return;this.sessionId=e;let t=e===``?void 0:this.storage.read(e);this.openGroupKeys=new Set(t?.open??[]),this.closedDefaultOpenGroupKeys=new Set(t?.closedDefaultOpen??[])}isOpen(e,t){return t?!this.closedDefaultOpenGroupKeys.has(e):this.openGroupKeys.has(e)}applyToggle(e,t,n){let r=this.isOpen(e,n),i=new Set(this.openGroupKeys),a=new Set(this.closedDefaultOpenGroupKeys);return n?(i.delete(e),t?a.delete(e):a.add(e)):(a.delete(e),t?i.add(e):i.delete(e)),(n?!a.has(e):i.has(e))===r&&Mv(i,this.openGroupKeys)&&Mv(a,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=i,this.closedDefaultOpenGroupKeys=a,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==``&&this.storage.write(this.sessionId,this.snapshot())}};function kv(e){return`${Ev}${e}`}function Av(e){if(Array.isArray(e))return{open:jv(e),closedDefaultOpen:[]};if(Nv(e))return{open:Array.isArray(e.open)?jv(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?jv(e.closedDefaultOpen):[]}}function jv(e){return e.filter(e=>typeof e==`string`)}function Mv(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Nv(e){return typeof e==`object`&&!!e}function Pv(e,t=0){let n=[],r=[],i=0,a=(e,t)=>{r.length||(i=t),r.push(e)},o=()=>{r.length&&(n.push({kind:`group`,messages:r,startIndex:i,endIndex:i+r.length-1}),r=[])};return e.forEach((e,r)=>{let i=e.parts.filter(t=>Rv(e,t)),s=e.parts.filter(t=>!Rv(e,t)),c=t+r,l={...e.source===void 0?{}:{source:e.source},...e.meta===void 0?{}:{meta:e.meta}},u={...l,...e.entryId===void 0?{}:{entryId:e.entryId},...e.previousAssistantEntryId===void 0?{}:{previousAssistantEntryId:e.previousAssistantEntryId},...e.canFork===void 0?{}:{canFork:e.canFork}};if(s.length&&a({role:e.role,parts:s,...l},c),i.length){o();let t={role:i.every(e=>e.type===`skillRead`)?`skill`:e.role,parts:i,...u};if(Iv(t)){let e=Lv(s);n.push({kind:`tool-image`,message:t,index:c,...e===void 0?{}:{toolName:e}})}else n.push({kind:`message`,message:t,index:c})}}),o(),n}function Fv(e){if(e.every(e=>e.source===`compaction`))return`${String(e.length)} history compaction ${e.length===1?`summary`:`summaries`}`;if(e.every(e=>e.source===`branch_summary`))return`${String(e.length)} branch ${e.length===1?`summary`:`summaries`}`;let t=e.reduce((e,t)=>(e[t.role]=(e[t.role]??0)+1,e),{}),n=Object.entries(t).map(([e,t])=>`${String(t)} ${e}`).join(` · `);return`${String(e.length)} ${e.length===1?`event`:`events`}${n===``?``:` · ${n}`}`}function Iv(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`image`)}function Lv(e){for(let t of e)if((t.type===`toolCall`||t.type===`toolExecution`||t.type===`toolResult`)&&t.toolName!==``)return t.toolName}function Rv(e,t){return e.source===`compaction`||e.source===`branch_summary`?!1:t.type===`skillInvocation`||t.type===`skillRead`||t.type===`image`||t.type===`text`&&(e.role===`user`||e.role===`assistant`||e.role===`system`||e.role===`bash`)}async function zv(e,t=Bv()){if(!t.isSecureContext)return t.fallbackWriteText(e);if(t.writeText!==void 0)try{return await t.writeText(e),!0}catch{return t.fallbackWriteText(e)}return t.fallbackWriteText(e)}function Bv(){let e=e=>Uv(e),t=Hv();return t===void 0?{isSecureContext:Vv(),fallbackWriteText:e}:{isSecureContext:Vv(),writeText:t,fallbackWriteText:e}}function Vv(){return typeof window<`u`&&window.isSecureContext}function Hv(){if(!(typeof navigator>`u`||!(`clipboard`in navigator)))return navigator.clipboard.writeText.bind(navigator.clipboard)}function Uv(e){if(typeof document>`u`)return!1;let t=document.activeElement,n=document.getSelection(),r=n===null?[]:Wv(n),i=document.createElement(`textarea`);i.value=e,i.readOnly=!0,i.setAttribute(`aria-hidden`,`true`),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`-9999px`,i.style.width=`1px`,i.style.height=`1px`,i.style.padding=`0`,i.style.border=`0`,i.style.opacity=`0`,i.style.pointerEvents=`none`,document.body.append(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length);try{return document.execCommand(`copy`)}catch{return!1}finally{i.remove(),Gv(n,r),Kv(t)}}function Wv(e){let t=[];for(let n=0;n<e.rangeCount;n+=1)t.push(e.getRangeAt(n));return t}function Gv(e,t){if(e!==null)try{e.removeAllRanges();for(let n of t)e.addRange(n)}catch{}}function Kv(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))try{e.focus({preventScroll:!0})}catch{e.focus()}}function qv(e,t){let n=Yv(Qv(e,t)),r={distanceFromBottom:e.scrollHeight-e.scrollTop};return n===void 0?r:{...r,markerId:n.id,markerOffset:n.offset}}function Jv(e,t,n){if(n!==void 0&&t.markerOffset!==void 0){let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=Xv(r,t.markerOffset);return}e.scrollTop=Zv(e.scrollHeight,t.distanceFromBottom)}function Yv(e){let t,n=-1/0,r,i=1/0;for(let a of e)a.offset<=0&&a.offset>=n?(t=a,n=a.offset):a.offset>0&&a.offset<i&&(r=a,i=a.offset);return t??r}function Xv(e,t){return e-t}function Zv(e,t){return Math.max(0,e-t)}function Qv(e,t){let n=e.getBoundingClientRect().top;return t.flatMap(e=>{let t=e.dataset.markerId;return t===void 0?[]:[{id:t,offset:e.getBoundingClientRect().top-n}]})}var $v=600,ey=1;function ty(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:ny(e)||ry(e)}function ny(e){return e.scrollTop<(e.topThreshold??Math.max($v,e.clientHeight))}function ry(e){return e.scrollHeight<=e.clientHeight+ey}var iy=`pi-webui:chat-scroll:`,ay=180,oy=48,sy=2,cy={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)}},ly={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}},uy=class{constructor(e=cy,t=ly){this.storage=e,this.scheduler=t}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(e,t,n=ay){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,t(e)},n)}savePosition(e,t,n,r=sy){if(e===``||t===void 0||!py(t))return`skipped`;try{if(hy(t,r))return this.storage.setItem(dy(e),JSON.stringify({mode:`bottom`})),`saved`;let i=_y(t,n);if(i===void 0)return`skipped`;let a=gy(t,i);return this.storage.setItem(dy(e),JSON.stringify(a)),`saved`}catch{return`skipped`}}restorePosition(e,t,n,r){let i=this.readPosition(e);return i===void 0?this.scrollToBottom(t):this.restoreExplicitPosition(i,t,n,r)}restoreExplicitPosition(e,t,n,r){if(e.mode===`bottom`)return this.scrollToBottom(t);if(t===void 0||!py(t))return{status:`skipped`};let i=yy(n,e.anchorId);if(i===void 0)return r?.fallbackToBottom===!1?{status:`missing`,position:e}:this.scrollToBottom(t);let a=t.getBoundingClientRect().top,o=i.getBoundingClientRect().top-a;return t.scrollTop+=o-e.offset,{status:`restored`}}readPosition(e){if(e!==``)try{let t=this.storage.getItem(dy(e));if(t===null||t===``)return;let n=JSON.parse(t);return fy(n)?n:void 0}catch{return}}scrollToBottom(e){return e===void 0||!py(e)?{status:`skipped`}:(e.scrollTop=e.scrollHeight,{status:`bottom`})}};function dy(e){return`${iy}${e}`}function fy(e){return typeof e!=`object`||!e||!(`mode`in e)?!1:e.mode===`bottom`||e.mode===`anchor`&&`anchorId`in e&&typeof e.anchorId==`string`&&e.anchorId!==``&&`offset`in e&&typeof e.offset==`number`}function py(e){return e.clientHeight>0&&e.scrollHeight>0}function my(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function hy(e,t=oy){return my(e)<t}function gy(e,t){let n=e.getBoundingClientRect().top;return{mode:`anchor`,anchorId:by(t)??``,offset:t.getBoundingClientRect().top-n}}function _y(e,t){let n=e.getBoundingClientRect(),r,i=-1/0,a,o=1/0;for(let e of t){if(by(e)===void 0)continue;let t=e.getBoundingClientRect();if(t.bottom<=t.top||t.bottom<n.top||t.top>n.bottom)continue;let s=t.top-n.top;s<=0&&s>=i?(r=e,i=s):s>0&&s<o&&(a=e,o=s)}return r??a}function vy(e,t){let n=e.getBoundingClientRect();return t.find(e=>{let t=e.getBoundingClientRect();return t.bottom>=n.top&&t.top<=n.bottom})}function yy(e,t){return e.find(e=>by(e)===t)}function by(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==``?e.dataset.scrollAnchorId:void 0}function xy(e){let{scrollHeight:t,clientHeight:n,scrollTop:r}=e;if(n<=0||t<=0)return{scrollRatio:0,viewportRatio:1,visible:!1};let i=t-n;return i<=20?{scrollRatio:0,viewportRatio:1,visible:!1}:{scrollRatio:Sy(r/i),viewportRatio:Sy(n/t),visible:!0}}function Sy(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Cy(e,t){return Sy(e*(1-t))}function wy(e,t,n,r){return r<=0?0:Sy((e-t+n)/r)}var Ty=22,Ey=2;function Dy(e,t){if(e.length===0)return[];let n=Number.isFinite(t)?Math.max(0,t):0,r=Math.max(0,n-Ty),i=e.map((e,t)=>({index:t,desiredTop:Sy(e.topRatio)*n-Ty/2})).sort((e,t)=>e.desiredTop-t.desiredTop||e.index-t.index),a=Array(e.length).fill(0),o=e=>{for(let t=0;t<i.length;t+=1){let n=i[t],r=e[t];n===void 0||r===void 0||(a[n.index]=Math.round(r))}return a};if(i.length===1)return o([Math.min(r,Math.max(0,i[0]?.desiredTop??0))]);if(i.length*Ty+(i.length-1)*Ey>n)return o(i.map((e,t)=>r*t/(i.length-1)));let s=i.map(({desiredTop:e})=>Math.min(r,Math.max(0,e)));for(let e=1;e<s.length;e+=1){let t=s[e-1],n=s[e];t===void 0||n===void 0||(s[e]=Math.max(n,t+24))}let c=s.length-1,l=s[c];l!==void 0&&(s[c]=Math.min(l,r));for(let e=c-1;e>=0;--e){let t=s[e+1],n=s[e];t===void 0||n===void 0||(s[e]=Math.min(n,t-24))}return o(s)}function Oy(e){if(typeof e!=`object`||!e||!(`ratio`in e))return;let t=e.ratio;if(!(typeof t!=`number`||!Number.isFinite(t)))return Sy(t)}function ky(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 Ay(e){return!Number.isFinite(e)||e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function jy(e){return!Number.isFinite(e)||e===0?`$0.0000`:`$${e.toFixed(4)}`}function My(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function Ny(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${String(Math.round(e/1e3))}k`:Math.round(e).toString():`0`}function Py(e){let t=[],n=e.tokens;t.push(`Input: ${My(n.input)}`),t.push(`Output: ${My(n.output)}`),t.push(`Cache read: ${My(n.cacheRead)}`),t.push(`Cache write: ${My(n.cacheWrite)}`),t.push(`Total: ${My(n.total)}`),e.cost>0&&t.push(`Cost: ${jy(e.cost)}`);let r=e.contextUsage;if(r!==void 0){let e=r.percent===null?`unknown`:`${r.percent.toFixed(1)}%`;t.push(`Context: ${e} of ${My(r.contextWindow)} tokens`)}return t.join(` | `)}function Fy(e){let t=0,n=0,r=0,i=0;for(let a of e)a.role===`user`&&(t+=1),a.role===`assistant`&&(n+=1,r+=a.parts.filter(e=>e.type===`toolCall`).length),a.role===`tool`&&(i+=a.parts.filter(e=>e.type===`toolResult`).length);return{user:t,assistant:n,toolCalls:r,toolResults:i,total:e.length}}function Iy(e,t,n){let r=[];t?.name!==void 0&&t.name!==``&&r.push({label:`Name`,value:t.name}),r.push({label:`ID`,value:t?.id??e.sessionId,copyValue:t?.id??e.sessionId}),t?.path!==void 0&&t.path!==``?r.push({label:`File`,value:t.path,copyValue:t.path}):t?.persisted===!1?r.push({label:`File`,value:`In-memory (transient)`}):r.push({label:`File`,value:e.persisted===!1?`In-memory (transient)`:`Unknown`});let i=[];n===void 0?e.messageCount!==void 0&&i.push({label:`Total`,value:My(e.messageCount)}):(i.push({label:`User`,value:My(n.user)}),i.push({label:`Assistant`,value:My(n.assistant)}),i.push({label:`Tool calls`,value:My(n.toolCalls)}),i.push({label:`Tool results`,value:My(n.toolResults)}),i.push({label:`Total`,value:My(n.total)}));let a=e.tokens,o=[{label:`Input`,value:My(a.input)},{label:`Output`,value:My(a.output)}];a.cacheRead>0&&o.push({label:`Cache read`,value:My(a.cacheRead)}),a.cacheWrite>0&&o.push({label:`Cache write`,value:My(a.cacheWrite)}),o.push({label:`Total`,value:My(a.total)}),e.cost>0&&o.push({label:`Cost`,value:jy(e.cost)});let s=e.contextUsage;if(s!==void 0){let e=s.percent===null?`?`:`${s.percent.toFixed(1)}%`;o.push({label:`Context`,value:`${e} / ${Ny(s.contextWindow)}`})}return{sessionRows:r,messageRows:i,tokenRows:o}}var Ly=class extends y{constructor(...e){super(...e),this.scrollRatio=0,this.viewportRatio=1,this.visible=!1,this.loadedPercent=100,this.markers=[],this._hovered=!1,this._nearestIndex=null,this._dragging=!1,this._grabOffset=0}_handlePointerDown(e){if(!this.visible)return;let t=this._rail;if(!t)return;this._dragging=!0,t.setPointerCapture(e.pointerId);let n=t.getBoundingClientRect(),r=Sy((e.clientY-n.top)/n.height),i=this._viewportTopRatio(),a=r>=i&&r<=i+this.viewportRatio;this._grabOffset=a?r-i:this.viewportRatio/2,this._dispatchScroll(r-this._grabOffset)}_handlePointerMove(e){if(!this._rail)return;let t=this._rail.getBoundingClientRect(),n=Sy((e.clientY-t.top)/t.height);if(this._dragging){this._dispatchScroll(n-this._grabOffset);return}this._nearestIndex=this._findNearestMarker(n)}_handlePointerUp(){this._dragging=!1}_handleKeyDown(e){if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault();let t=this.viewportRatio/2,n=e.key===`ArrowUp`?-t:t,r=Sy(this._viewportTopRatio()+n);this._dispatchScroll(r)}}_viewportTopRatio(){return Cy(this.scrollRatio,this.viewportRatio)}_dispatchScroll(e){let t=Sy(e);this.dispatchEvent(new CustomEvent(`minimap-scroll-to`,{detail:{ratio:t},bubbles:!0,composed:!0}))}_findNearestMarker(e){let t=this.markers;if(t.length===0)return null;let n=t[0];if(n===void 0)return null;let r=0,i=Math.abs(n.topRatio-e);for(let n=1;n<t.length;n++){let a=t[n];if(a===void 0)continue;let o=Math.abs(a.topRatio-e);o<i&&(i=o,r=n)}return r}render(){return this.visible?g`${this._renderRail()}${this._renderTooltips()}`:g``}_renderRail(){let e=this._viewportTopRatio()*100,t=this.viewportRatio*100,n=this.loadedPercent>=100?`all messages loaded`:`${String(Math.round(this.loadedPercent))}% of messages loaded`;return g`
|
|
2213
|
+
`}};B([x({attribute:!1})],Tv.prototype,`tree`,void 0),B([x({attribute:!1})],Tv.prototype,`onNavigate`,void 0),B([x({attribute:!1})],Tv.prototype,`onAbort`,void 0),B([x({attribute:!1})],Tv.prototype,`onCancel`,void 0),B([S()],Tv.prototype,`selectedId`,void 0),B([S()],Tv.prototype,`foldedIds`,void 0),B([S()],Tv.prototype,`step`,void 0),B([S()],Tv.prototype,`summaryMode`,void 0),B([S()],Tv.prototype,`customInstructions`,void 0),B([S()],Tv.prototype,`busy`,void 0),B([S()],Tv.prototype,`aborting`,void 0),B([S()],Tv.prototype,`error`,void 0),B([S()],Tv.prototype,`statusMessage`,void 0),Tv=B([b(`session-tree-navigator`)],Tv);function Ev(e){return Math.min(Math.max(0,e),wv)}function Dv(e){return e===`user`||e===`custom-message`}function Ov(e){switch(e){case`user`:return`User`;case`assistant`:return`Assistant`;case`tool-result`:return`Tool result`;case`bash`:return`Shell`;case`custom-message`:return`Custom message`;case`compaction`:return`Compaction`;case`branch-summary`:return`Branch summary`;case`model-change`:return`Model`;case`thinking-level-change`:return`Thinking`;case`session-info`:return`Session info`;case`label`:return`Label`;case`custom`:return`Custom`;case`other`:return`Other`}}function kv(e){return e===`model-change`||e===`thinking-level-change`||e===`session-info`||e===`label`||e===`custom`||e===`other`}function Av(e){return e instanceof Error?e.message:String(e)}var jv=`pi-webui:chat-groups:`,Mv={read(e){try{if(typeof localStorage>`u`)return;let t=localStorage.getItem(Pv(e));return t===null||t===``?void 0:Fv(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>`u`)return;localStorage.setItem(Pv(e),JSON.stringify(t))}catch{}}},Nv=class{constructor(e=Mv){this.storage=e,this.sessionId=``,this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(e){if(this.sessionId===e)return;this.sessionId=e;let t=e===``?void 0:this.storage.read(e);this.openGroupKeys=new Set(t?.open??[]),this.closedDefaultOpenGroupKeys=new Set(t?.closedDefaultOpen??[])}isOpen(e,t){return t?!this.closedDefaultOpenGroupKeys.has(e):this.openGroupKeys.has(e)}applyToggle(e,t,n){let r=this.isOpen(e,n),i=new Set(this.openGroupKeys),a=new Set(this.closedDefaultOpenGroupKeys);return n?(i.delete(e),t?a.delete(e):a.add(e)):(a.delete(e),t?i.add(e):i.delete(e)),(n?!a.has(e):i.has(e))===r&&Lv(i,this.openGroupKeys)&&Lv(a,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=i,this.closedDefaultOpenGroupKeys=a,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==``&&this.storage.write(this.sessionId,this.snapshot())}};function Pv(e){return`${jv}${e}`}function Fv(e){if(Array.isArray(e))return{open:Iv(e),closedDefaultOpen:[]};if(Rv(e))return{open:Array.isArray(e.open)?Iv(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?Iv(e.closedDefaultOpen):[]}}function Iv(e){return e.filter(e=>typeof e==`string`)}function Lv(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Rv(e){return typeof e==`object`&&!!e}function zv(e,t=0){let n=[],r=[],i=0,a=(e,t)=>{r.length||(i=t),r.push(e)},o=()=>{r.length&&(n.push({kind:`group`,messages:r,startIndex:i,endIndex:i+r.length-1}),r=[])};return e.forEach((e,r)=>{let i=e.parts.filter(t=>Uv(e,t)),s=e.parts.filter(t=>!Uv(e,t)),c=t+r,l={...e.source===void 0?{}:{source:e.source},...e.meta===void 0?{}:{meta:e.meta}},u={...l,...e.entryId===void 0?{}:{entryId:e.entryId},...e.previousAssistantEntryId===void 0?{}:{previousAssistantEntryId:e.previousAssistantEntryId},...e.canFork===void 0?{}:{canFork:e.canFork}};if(s.length&&a({role:e.role,parts:s,...l},c),i.length){o();let t={role:i.every(e=>e.type===`skillRead`)?`skill`:e.role,parts:i,...u};if(Vv(t)){let e=Hv(s);n.push({kind:`tool-image`,message:t,index:c,...e===void 0?{}:{toolName:e}})}else n.push({kind:`message`,message:t,index:c})}}),o(),n}function Bv(e){if(e.every(e=>e.source===`compaction`))return`${String(e.length)} history compaction ${e.length===1?`summary`:`summaries`}`;if(e.every(e=>e.source===`branch_summary`))return`${String(e.length)} branch ${e.length===1?`summary`:`summaries`}`;let t=e.reduce((e,t)=>(e[t.role]=(e[t.role]??0)+1,e),{}),n=Object.entries(t).map(([e,t])=>`${String(t)} ${e}`).join(` · `);return`${String(e.length)} ${e.length===1?`event`:`events`}${n===``?``:` · ${n}`}`}function Vv(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`image`)}function Hv(e){for(let t of e)if((t.type===`toolCall`||t.type===`toolExecution`||t.type===`toolResult`)&&t.toolName!==``)return t.toolName}function Uv(e,t){return e.source===`compaction`||e.source===`branch_summary`?!1:t.type===`skillInvocation`||t.type===`skillRead`||t.type===`image`||t.type===`text`&&(e.role===`user`||e.role===`assistant`||e.role===`system`||e.role===`bash`)}async function Wv(e,t=Gv()){if(!t.isSecureContext)return t.fallbackWriteText(e);if(t.writeText!==void 0)try{return await t.writeText(e),!0}catch{return t.fallbackWriteText(e)}return t.fallbackWriteText(e)}function Gv(){let e=e=>Jv(e),t=qv();return t===void 0?{isSecureContext:Kv(),fallbackWriteText:e}:{isSecureContext:Kv(),writeText:t,fallbackWriteText:e}}function Kv(){return typeof window<`u`&&window.isSecureContext}function qv(){if(!(typeof navigator>`u`||!(`clipboard`in navigator)))return navigator.clipboard.writeText.bind(navigator.clipboard)}function Jv(e){if(typeof document>`u`)return!1;let t=document.activeElement,n=document.getSelection(),r=n===null?[]:Yv(n),i=document.createElement(`textarea`);i.value=e,i.readOnly=!0,i.setAttribute(`aria-hidden`,`true`),i.style.position=`fixed`,i.style.top=`0`,i.style.left=`-9999px`,i.style.width=`1px`,i.style.height=`1px`,i.style.padding=`0`,i.style.border=`0`,i.style.opacity=`0`,i.style.pointerEvents=`none`,document.body.append(i),i.focus(),i.select(),i.setSelectionRange(0,i.value.length);try{return document.execCommand(`copy`)}catch{return!1}finally{i.remove(),Xv(n,r),Zv(t)}}function Yv(e){let t=[];for(let n=0;n<e.rangeCount;n+=1)t.push(e.getRangeAt(n));return t}function Xv(e,t){if(e!==null)try{e.removeAllRanges();for(let n of t)e.addRange(n)}catch{}}function Zv(e){if(!(typeof HTMLElement>`u`||!(e instanceof HTMLElement)))try{e.focus({preventScroll:!0})}catch{e.focus()}}function Qv(e,t){let n=ey(ry(e,t)),r={distanceFromBottom:e.scrollHeight-e.scrollTop};return n===void 0?r:{...r,markerId:n.id,markerOffset:n.offset}}function $v(e,t,n){if(n!==void 0&&t.markerOffset!==void 0){let r=n.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=ty(r,t.markerOffset);return}e.scrollTop=ny(e.scrollHeight,t.distanceFromBottom)}function ey(e){let t,n=-1/0,r,i=1/0;for(let a of e)a.offset<=0&&a.offset>=n?(t=a,n=a.offset):a.offset>0&&a.offset<i&&(r=a,i=a.offset);return t??r}function ty(e,t){return e-t}function ny(e,t){return Math.max(0,e-t)}function ry(e,t){let n=e.getBoundingClientRect().top;return t.flatMap(e=>{let t=e.dataset.markerId;return t===void 0?[]:[{id:t,offset:e.getBoundingClientRect().top-n}]})}var iy=600,ay=1;function oy(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:sy(e)||cy(e)}function sy(e){return e.scrollTop<(e.topThreshold??Math.max(iy,e.clientHeight))}function cy(e){return e.scrollHeight<=e.clientHeight+ay}var ly=`pi-webui:chat-scroll:`,uy=180,dy=48,fy=2,py={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)}},my={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}},hy=class{constructor(e=py,t=my){this.storage=e,this.scheduler=t}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(e,t,n=uy){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,t(e)},n)}savePosition(e,t,n,r=fy){if(e===``||t===void 0||!vy(t))return`skipped`;try{if(by(t,r))return this.storage.setItem(gy(e),JSON.stringify({mode:`bottom`})),`saved`;let i=Sy(t,n);if(i===void 0)return`skipped`;let a=xy(t,i);return this.storage.setItem(gy(e),JSON.stringify(a)),`saved`}catch{return`skipped`}}restorePosition(e,t,n,r){let i=this.readPosition(e);return i===void 0?this.scrollToBottom(t):this.restoreExplicitPosition(i,t,n,r)}restoreExplicitPosition(e,t,n,r){if(e.mode===`bottom`)return this.scrollToBottom(t);if(t===void 0||!vy(t))return{status:`skipped`};let i=wy(n,e.anchorId);if(i===void 0)return r?.fallbackToBottom===!1?{status:`missing`,position:e}:this.scrollToBottom(t);let a=t.getBoundingClientRect().top,o=i.getBoundingClientRect().top-a;return t.scrollTop+=o-e.offset,{status:`restored`}}readPosition(e){if(e!==``)try{let t=this.storage.getItem(gy(e));if(t===null||t===``)return;let n=JSON.parse(t);return _y(n)?n:void 0}catch{return}}scrollToBottom(e){return e===void 0||!vy(e)?{status:`skipped`}:(e.scrollTop=e.scrollHeight,{status:`bottom`})}};function gy(e){return`${ly}${e}`}function _y(e){return typeof e!=`object`||!e||!(`mode`in e)?!1:e.mode===`bottom`||e.mode===`anchor`&&`anchorId`in e&&typeof e.anchorId==`string`&&e.anchorId!==``&&`offset`in e&&typeof e.offset==`number`}function vy(e){return e.clientHeight>0&&e.scrollHeight>0}function yy(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function by(e,t=dy){return yy(e)<t}function xy(e,t){let n=e.getBoundingClientRect().top;return{mode:`anchor`,anchorId:Ty(t)??``,offset:t.getBoundingClientRect().top-n}}function Sy(e,t){let n=e.getBoundingClientRect(),r,i=-1/0,a,o=1/0;for(let e of t){if(Ty(e)===void 0)continue;let t=e.getBoundingClientRect();if(t.bottom<=t.top||t.bottom<n.top||t.top>n.bottom)continue;let s=t.top-n.top;s<=0&&s>=i?(r=e,i=s):s>0&&s<o&&(a=e,o=s)}return r??a}function Cy(e,t){let n=e.getBoundingClientRect();return t.find(e=>{let t=e.getBoundingClientRect();return t.bottom>=n.top&&t.top<=n.bottom})}function wy(e,t){return e.find(e=>Ty(e)===t)}function Ty(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==``?e.dataset.scrollAnchorId:void 0}function Ey(e){let{scrollHeight:t,clientHeight:n,scrollTop:r}=e;if(n<=0||t<=0)return{scrollRatio:0,viewportRatio:1,visible:!1};let i=t-n;return i<=20?{scrollRatio:0,viewportRatio:1,visible:!1}:{scrollRatio:Dy(r/i),viewportRatio:Dy(n/t),visible:!0}}function Dy(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Oy(e,t){return Dy(e*(1-t))}function ky(e,t,n,r){return r<=0?0:Dy((e-t+n)/r)}var Ay=22,jy=2;function My(e,t){if(e.length===0)return[];let n=Number.isFinite(t)?Math.max(0,t):0,r=Math.max(0,n-Ay),i=e.map((e,t)=>({index:t,desiredTop:Dy(e.topRatio)*n-Ay/2})).sort((e,t)=>e.desiredTop-t.desiredTop||e.index-t.index),a=Array(e.length).fill(0),o=e=>{for(let t=0;t<i.length;t+=1){let n=i[t],r=e[t];n===void 0||r===void 0||(a[n.index]=Math.round(r))}return a};if(i.length===1)return o([Math.min(r,Math.max(0,i[0]?.desiredTop??0))]);if(i.length*Ay+(i.length-1)*jy>n)return o(i.map((e,t)=>r*t/(i.length-1)));let s=i.map(({desiredTop:e})=>Math.min(r,Math.max(0,e)));for(let e=1;e<s.length;e+=1){let t=s[e-1],n=s[e];t===void 0||n===void 0||(s[e]=Math.max(n,t+24))}let c=s.length-1,l=s[c];l!==void 0&&(s[c]=Math.min(l,r));for(let e=c-1;e>=0;--e){let t=s[e+1],n=s[e];t===void 0||n===void 0||(s[e]=Math.min(n,t-24))}return o(s)}function Ny(e){if(typeof e!=`object`||!e||!(`ratio`in e))return;let t=e.ratio;if(!(typeof t!=`number`||!Number.isFinite(t)))return Dy(t)}function Py(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 Fy(e){return!Number.isFinite(e)||e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Iy(e){return!Number.isFinite(e)||e===0?`$0.0000`:`$${e.toFixed(4)}`}function Ly(e){return Number.isFinite(e)?Math.round(e).toLocaleString():`0`}function Ry(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${String(Math.round(e/1e3))}k`:Math.round(e).toString():`0`}function zy(e){let t=[],n=e.tokens;t.push(`Input: ${Ly(n.input)}`),t.push(`Output: ${Ly(n.output)}`),t.push(`Cache read: ${Ly(n.cacheRead)}`),t.push(`Cache write: ${Ly(n.cacheWrite)}`),t.push(`Total: ${Ly(n.total)}`),e.cost>0&&t.push(`Cost: ${Iy(e.cost)}`);let r=e.contextUsage;if(r!==void 0){let e=r.percent===null?`unknown`:`${r.percent.toFixed(1)}%`;t.push(`Context: ${e} of ${Ly(r.contextWindow)} tokens`)}return t.join(` | `)}function By(e){let t=0,n=0,r=0,i=0;for(let a of e)a.role===`user`&&(t+=1),a.role===`assistant`&&(n+=1,r+=a.parts.filter(e=>e.type===`toolCall`).length),a.role===`tool`&&(i+=a.parts.filter(e=>e.type===`toolResult`).length);return{user:t,assistant:n,toolCalls:r,toolResults:i,total:e.length}}function Vy(e,t,n){let r=[];t?.name!==void 0&&t.name!==``&&r.push({label:`Name`,value:t.name}),r.push({label:`ID`,value:t?.id??e.sessionId,copyValue:t?.id??e.sessionId}),t?.path!==void 0&&t.path!==``?r.push({label:`File`,value:t.path,copyValue:t.path}):t?.persisted===!1?r.push({label:`File`,value:`In-memory (transient)`}):r.push({label:`File`,value:e.persisted===!1?`In-memory (transient)`:`Unknown`});let i=[];n===void 0?e.messageCount!==void 0&&i.push({label:`Total`,value:Ly(e.messageCount)}):(i.push({label:`User`,value:Ly(n.user)}),i.push({label:`Assistant`,value:Ly(n.assistant)}),i.push({label:`Tool calls`,value:Ly(n.toolCalls)}),i.push({label:`Tool results`,value:Ly(n.toolResults)}),i.push({label:`Total`,value:Ly(n.total)}));let a=e.tokens,o=[{label:`Input`,value:Ly(a.input)},{label:`Output`,value:Ly(a.output)}];a.cacheRead>0&&o.push({label:`Cache read`,value:Ly(a.cacheRead)}),a.cacheWrite>0&&o.push({label:`Cache write`,value:Ly(a.cacheWrite)}),o.push({label:`Total`,value:Ly(a.total)}),e.cost>0&&o.push({label:`Cost`,value:Iy(e.cost)});let s=e.contextUsage;if(s!==void 0){let e=s.percent===null?`?`:`${s.percent.toFixed(1)}%`;o.push({label:`Context`,value:`${e} / ${Ry(s.contextWindow)}`})}return{sessionRows:r,messageRows:i,tokenRows:o}}var Hy=class extends y{constructor(...e){super(...e),this.scrollRatio=0,this.viewportRatio=1,this.visible=!1,this.loadedPercent=100,this.markers=[],this._hovered=!1,this._nearestIndex=null,this._dragging=!1,this._grabOffset=0}_handlePointerDown(e){if(!this.visible)return;let t=this._rail;if(!t)return;this._dragging=!0,t.setPointerCapture(e.pointerId);let n=t.getBoundingClientRect(),r=Dy((e.clientY-n.top)/n.height),i=this._viewportTopRatio(),a=r>=i&&r<=i+this.viewportRatio;this._grabOffset=a?r-i:this.viewportRatio/2,this._dispatchScroll(r-this._grabOffset)}_handlePointerMove(e){if(!this._rail)return;let t=this._rail.getBoundingClientRect(),n=Dy((e.clientY-t.top)/t.height);if(this._dragging){this._dispatchScroll(n-this._grabOffset);return}this._nearestIndex=this._findNearestMarker(n)}_handlePointerUp(){this._dragging=!1}_handleKeyDown(e){if(e.key===`ArrowUp`||e.key===`ArrowDown`){e.preventDefault();let t=this.viewportRatio/2,n=e.key===`ArrowUp`?-t:t,r=Dy(this._viewportTopRatio()+n);this._dispatchScroll(r)}}_viewportTopRatio(){return Oy(this.scrollRatio,this.viewportRatio)}_dispatchScroll(e){let t=Dy(e);this.dispatchEvent(new CustomEvent(`minimap-scroll-to`,{detail:{ratio:t},bubbles:!0,composed:!0}))}_findNearestMarker(e){let t=this.markers;if(t.length===0)return null;let n=t[0];if(n===void 0)return null;let r=0,i=Math.abs(n.topRatio-e);for(let n=1;n<t.length;n++){let a=t[n];if(a===void 0)continue;let o=Math.abs(a.topRatio-e);o<i&&(i=o,r=n)}return r}render(){return this.visible?g`${this._renderRail()}${this._renderTooltips()}`:g``}_renderRail(){let e=this._viewportTopRatio()*100,t=this.viewportRatio*100,n=this.loadedPercent>=100?`all messages loaded`:`${String(Math.round(this.loadedPercent))}% of messages loaded`;return g`
|
|
2090
2214
|
<div
|
|
2091
2215
|
class="rail"
|
|
2092
2216
|
role="scrollbar"
|
|
@@ -2120,7 +2244,7 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
2120
2244
|
class=${`marker-dot${r?` user`:` assistant`}${n?` nearest`:``}`}
|
|
2121
2245
|
></div>
|
|
2122
2246
|
</div>
|
|
2123
|
-
`}_renderTooltips(){if(!this._hovered)return null;let e=
|
|
2247
|
+
`}_renderTooltips(){if(!this._hovered)return null;let e=My(this.markers,this._rail?.clientHeight??600);return this.markers.map((t,n)=>{let r=e[n];if(t.preview===``||r===void 0)return null;let i=this._nearestIndex===n;return g`
|
|
2124
2248
|
<div
|
|
2125
2249
|
class=${`tooltip ${t.role}${i?` nearest`:``}`}
|
|
2126
2250
|
style=${`top:${String(r)}px`}
|
|
@@ -2258,14 +2382,14 @@ This will delete every archived session on this machine regardless of age or cle
|
|
|
2258
2382
|
transition: none;
|
|
2259
2383
|
}
|
|
2260
2384
|
}
|
|
2261
|
-
`}};B([x({type:Number})],
|
|
2262
|
-
]`).replace(`lheading`,
|
|
2263
|
-
`),n=t.length-1;for(;n>=0&&
|
|
2264
|
-
`)}function
|
|
2385
|
+
`}};B([x({type:Number})],Hy.prototype,`scrollRatio`,void 0),B([x({type:Number})],Hy.prototype,`viewportRatio`,void 0),B([x({type:Boolean})],Hy.prototype,`visible`,void 0),B([x({type:Number})],Hy.prototype,`loadedPercent`,void 0),B([x({attribute:!1})],Hy.prototype,`markers`,void 0),B([S()],Hy.prototype,`_hovered`,void 0),B([S()],Hy.prototype,`_nearestIndex`,void 0),B([C(`.rail`)],Hy.prototype,`_rail`,void 0),Hy=B([b(`chat-minimap`)],Hy);var Uy=class extends C_{constructor(e){if(super(e),this.it=v,e.type!==x_.CHILD)throw Error(this.constructor.directiveName+`() can only be used in child bindings`)}render(e){if(e===v||e==null)return this._t=void 0,this.it=e;if(e===Qe)return e;if(typeof e!=`string`)throw Error(this.constructor.directiveName+`() called with a non-string value`);if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};Uy.directiveName=`unsafeHTML`,Uy.resultType=1;var Wy=S_(Uy);function Gy(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ky=Gy();function qy(e){Ky=e}var Jy={exec:()=>null};function Yy(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function U(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Zy.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Xy=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Zy={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=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Yy(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Yy(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Yy(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Yy(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Yy(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Yy(e=>RegExp(`^ {0,${e}}>`))},Qy=/^(?:[ \t]*(?:\n|$))+/,$y=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,eb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,tb=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rb=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ib=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ab=U(ib).replace(/bull/g,rb).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(),ob=U(ib).replace(/bull/g,rb).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(),sb=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,cb=/^[^\n]+/,lb=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ub=U(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,lb).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),db=U(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,rb).getRegex(),fb=`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`,pb=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,mb=U(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n+|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n+|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\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`,pb).replace(`tag`,fb).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),hb=e=>U(sb).replace(`hr`,tb).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`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,fb).getRegex(),gb=hb(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),_b=hb(/ {0,3}(?:[*+-]|\d{1,9}[.)])[ \t]+[^ \t\n]/),vb={blockquote:U(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,_b).getRegex(),code:$y,def:ub,fences:eb,heading:nb,hr:tb,html:mb,lheading:ab,list:db,newline:Qy,paragraph:gb,table:Jy,text:cb},yb=U(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,tb).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`,fb).getRegex(),bb={...vb,lheading:ob,table:yb,paragraph:U(sb).replace(`hr`,tb).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,yb).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`,fb).getRegex()},xb={...vb,html:U(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,pb).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:Jy,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:U(sb).replace(`hr`,tb).replace(`heading`,` *#{1,6} *[^
|
|
2386
|
+
]`).replace(`lheading`,ab).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Sb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Cb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,wb=/^( {2,}|\\)\n(?!\s*$)/,Tb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Eb=/[\p{P}\p{S}]/u,Db=/[\s\p{P}\p{S}]/u,Ob=/[^\s\p{P}\p{S}]/u,kb=U(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Db).getRegex(),Ab=/(?!~)[\p{P}\p{S}]/u,jb=/(?!~)[\s\p{P}\p{S}]/u,Mb=/(?:[^\s\p{P}\p{S}]|~)/u,Nb=U(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Xy?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Pb=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Fb=U(Pb,`u`).replace(/punct/g,Eb).getRegex(),Ib=U(Pb,`u`).replace(/punct/g,Ab).getRegex(),Lb=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Rb=U(Lb,`gu`).replace(/notPunctSpace/g,Ob).replace(/punctSpace/g,Db).replace(/punct/g,Eb).getRegex(),zb=U(Lb,`gu`).replace(/notPunctSpace/g,Mb).replace(/punctSpace/g,jb).replace(/punct/g,Ab).getRegex(),Bb=U(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ob).replace(/punctSpace/g,Db).replace(/punct/g,Eb).getRegex(),Vb=U(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Eb).getRegex(),Hb=U(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ob).replace(/punctSpace/g,Db).replace(/punct/g,Eb).getRegex(),Ub=U(/\\(punct)/,`gu`).replace(/punct/g,Eb).getRegex(),Wb=U(/^<(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(),Gb=U(pb).replace(`(?:-->|$)`,`-->`).getRegex(),Kb=U(`^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`,Gb).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qb=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Jb=U(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,qb).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yb=U(/^!?\[(label)\]\[(ref)\]/).replace(`label`,qb).replace(`ref`,lb).getRegex(),Xb=U(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,lb).getRegex(),Zb=U(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Yb).replace(`nolink`,Xb).getRegex(),Qb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$b={_backpedal:Jy,anyPunctuation:Ub,autolink:Wb,blockSkip:Nb,br:wb,code:Cb,del:Jy,delLDelim:Jy,delRDelim:Jy,emStrongLDelim:Fb,emStrongRDelimAst:Rb,emStrongRDelimUnd:Bb,escape:Sb,link:Jb,nolink:Xb,punctuation:kb,reflink:Yb,reflinkSearch:Zb,tag:Kb,text:Tb,url:Jy},ex={...$b,link:U(/^!?\[(label)\]\((.*?)\)/).replace(`label`,qb).getRegex(),reflink:U(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,qb).getRegex()},tx={...$b,emStrongRDelimAst:zb,emStrongLDelim:Ib,delLDelim:Vb,delRDelim:Hb,url:U(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Qb).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:U(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Qb).getRegex()},nx={...tx,br:U(wb).replace(`{2,}`,`*`).getRegex(),text:U(tx.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},rx={normal:vb,gfm:bb,pedantic:xb},ix={normal:$b,gfm:tx,breaks:nx,pedantic:ex},ax={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ox=e=>ax[e];function sx(e,t){if(t){if(Zy.escapeTest.test(e))return e.replace(Zy.escapeReplace,ox)}else if(Zy.escapeTestNoEncode.test(e))return e.replace(Zy.escapeReplaceNoEncode,ox);return e}function cx(e){try{e=encodeURI(e).replace(Zy.percentDecode,`%`)}catch{return null}return e}function lx(e,t){let n=e.replace(Zy.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Zy.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Zy.slashPipe,`|`);return n}function ux(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function dx(e){let t=e.split(`
|
|
2387
|
+
`),n=t.length-1;for(;n>=0&&Zy.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
2388
|
+
`)}function fx(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function px(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function mx(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function hx(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
2265
2389
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
2266
|
-
`)}var
|
|
2267
|
-
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:
|
|
2268
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
2390
|
+
`)}var gx=class{options;rules;lexer;constructor(e){this.options=e||Ky}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 e=this.options.pedantic?t[0]:dx(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=hx(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ux(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:ux(t[0],`
|
|
2391
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:ux(t[0],`
|
|
2392
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ux(t[0],`
|
|
2269
2393
|
`).split(`
|
|
2270
2394
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
2271
2395
|
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -2276,20 +2400,20 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2276
2400
|
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
2277
2401
|
`+e.join(`
|
|
2278
2402
|
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
2279
|
-
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=
|
|
2403
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=px(t[2].split(`
|
|
2280
2404
|
`,1)[0],t[1].length),l=e.split(`
|
|
2281
2405
|
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
2282
2406
|
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
2283
2407
|
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
2284
2408
|
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
2285
2409
|
`+l}u=!l.trim(),r+=p+`
|
|
2286
|
-
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=
|
|
2287
|
-
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=
|
|
2288
|
-
`):[],a={type:`table`,raw:
|
|
2289
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
2410
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=dx(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=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:e,raw:ux(t[0],`
|
|
2411
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=lx(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
2412
|
+
`):[],a={type:`table`,raw:ux(t[0],`
|
|
2413
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(lx(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:ux(t[0],`
|
|
2290
2414
|
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
2291
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}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 e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=
|
|
2292
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(
|
|
2415
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}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 e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ux(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=fx(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),mx(t,{href:n&&n.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 n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return mx(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},_x=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ky,this.options.tokenizer=this.options.tokenizer||new gx,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 t={other:Zy,block:rx.normal,inline:ix.normal};this.options.pedantic?(t.block=rx.pedantic,t.inline=ix.pedantic):this.options.gfm&&(t.block=rx.gfm,this.options.breaks?t.inline=ix.breaks:t.inline=ix.gfm),this.tokenizer.rules=t}static get rules(){return{block:rx,inline:ix}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Zy.carriageReturn,`
|
|
2416
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Zy.tabCharGlobal,` `).replace(Zy.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
2293
2417
|
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
2294
2418
|
`)?``:`
|
|
2295
2419
|
`)+i.raw,n.text+=`
|
|
@@ -2302,9 +2426,9 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
2302
2426
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
2303
2427
|
`)?``:`
|
|
2304
2428
|
`)+i.raw,n.text+=`
|
|
2305
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``,s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},
|
|
2306
|
-
`;return r?`<pre><code class="language-`+
|
|
2307
|
-
`:`<pre><code>`+(n?i:
|
|
2429
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``,s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},vx=class{options;parser;constructor(e){this.options=e||Ky}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Zy.notSpaceStart)?.[0],i=e.replace(Zy.endingNewline,``)+`
|
|
2430
|
+
`;return r?`<pre><code class="language-`+sx(r)+`">`+(n?i:sx(i,!0))+`</code></pre>
|
|
2431
|
+
`:`<pre><code>`+(n?i:sx(i,!0))+`</code></pre>
|
|
2308
2432
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
2309
2433
|
${this.parser.parse(e)}</blockquote>
|
|
2310
2434
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -2320,19 +2444,19 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
2320
2444
|
`}tablerow({text:e}){return`<tr>
|
|
2321
2445
|
${e}</tr>
|
|
2322
2446
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
2323
|
-
`}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>${
|
|
2324
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+
|
|
2447
|
+
`}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>${sx(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=cx(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+sx(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=cx(e);if(i===null)return sx(n);e=i;let a=`<img src="${e}" alt="${sx(n)}"`;return t&&(a+=` title="${sx(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:sx(e.text)}},yx=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}},bx=class e{options;renderer;textRenderer;constructor(e){this.options=e||Ky,this.options.renderer=this.options.renderer||new vx,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new yx}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},xx=class{options;block;constructor(e){this.options=e||Ky}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?_x.lex:_x.lexInline}provideParser(e=this.block){return e?bx.parse:bx.parseInline}},Sx=new class{defaults=Gy();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=bx;Renderer=vx;TextRenderer=yx;Lexer=_x;Tokenizer=gx;Hooks=xx;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new vx(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new gx(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new xx;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];xx.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&xx.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return _x.lex(e,t??this.defaults)}parser(e,t){return bx.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?_x.lex:_x.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?bx.parse:bx.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?_x.lex:_x.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?bx.parse:bx.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
2448
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+sx(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return Sx.parse(e,t)}W.options=W.setOptions=function(e){return Sx.setOptions(e),W.defaults=Sx.defaults,qy(W.defaults),W},W.getDefaults=Gy,W.defaults=Ky,W.use=function(...e){return Sx.use(...e),W.defaults=Sx.defaults,qy(W.defaults),W},W.walkTokens=function(e,t){return Sx.walkTokens(e,t)},W.parseInline=Sx.parseInline,W.Parser=bx,W.parser=bx.parse,W.Renderer=vx,W.TextRenderer=yx,W.Lexer=_x,W.lexer=_x.lex,W.Tokenizer=gx,W.Hooks=xx,W.parse=W,W.options,W.setOptions,W.use,W.walkTokens,W.parseInline,bx.parse,_x.lex;var Cx=new W.Renderer;Cx.html=({text:e})=>Dx(e);var wx=300,Tx=new Map;function Ex(e){let t=Tx.get(e);if(t!==void 0)return t;let n=Ox(W.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:Cx}));if(Tx.set(e,n),Tx.size>wx){let e=Tx.keys().next().value;e!==void 0&&Tx.delete(e)}return n}function Dx(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function Ox(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, iframe, object, embed`).forEach(e=>{e.remove()}),t.content.querySelectorAll(`*`).forEach(e=>{for(let t of[...e.attributes]){let n=t.name.toLowerCase();n.startsWith(`on`)&&e.removeAttribute(t.name),(n===`href`||n===`src`)&&!kx(t.value)&&e.removeAttribute(t.name)}e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noreferrer noopener`))}),t.innerHTML}function kx(e){if(e.startsWith(`#`)||e.startsWith(`/`))return!0;try{return[`http:`,`https:`,`mailto:`].includes(new URL(e).protocol)}catch{return!1}}var Ax=class extends y{constructor(...e){super(...e),this.text=``,this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`.code-copy-button`);if(!(t instanceof HTMLButtonElement))return;let n=t.closest(`.code-block-wrapper`);if(!(n instanceof HTMLElement))return;let r=n.querySelector(`pre code`);r instanceof HTMLElement&&this.copyCode(r.textContent,t)}}render(){return g`<div class="formatted" dir="auto" @click=${this.onFormattedClick}>${Wy(Ex(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;let t=document.createElement(`div`);t.className=`code-block-wrapper`;let n=document.createElement(`button`);n.type=`button`,n.className=`code-copy-button`,n.title=`Copy code block`,n.setAttribute(`aria-label`,`Copy code block`);let r=document.createElement(`span`);r.setAttribute(`aria-hidden`,`true`),r.textContent=`⧉`,n.append(r),e.before(t),t.append(e,n)})}async copyCode(e,t){let n=await Wv(e);this.setCopyButtonState(t,n?`copied`:`failed`),window.setTimeout(()=>{this.setCopyButtonState(t,`idle`)},1200)}setCopyButtonState(e,t){let n=e.querySelector(`span`);n!==null&&(n.textContent=t===`copied`?`✓`:`⧉`);let r=t===`copied`?`Copied code block`:t===`failed`?`Failed to copy code block`:`Copy code block`;e.title=r,e.setAttribute(`aria-label`,r)}static{this.styles=Yp}};B([x()],Ax.prototype,`text`,void 0),Ax=B([b(`formatted-text`)],Ax);var jx=180,Mx=class extends y{constructor(...e){super(...e),this.showFullDiff=!1,this.copied=!1,this.diffOpen=!0}render(){let e=this.execution;if(e===void 0)return null;let t=Px(e.args),n=Ix(e.details),r=e.preview,i=n??r?.diff,a=i===void 0?void 0:Lx(i),o=n!==void 0&&r?.diff!==void 0&&n!==r.diff,s=e.status===`error`?e.resultText:r?.error,c=i===void 0?e.resultText:void 0,l=Nx(e,t);return g`
|
|
2325
2449
|
<section class=${`tool-card ${e.status}`}>
|
|
2326
2450
|
<div class="tool-header">
|
|
2327
2451
|
<div class="tool-title">
|
|
2328
|
-
<span class="status-icon" aria-hidden="true">${
|
|
2452
|
+
<span class="status-icon" aria-hidden="true">${Vx(e.status)}</span>
|
|
2329
2453
|
<strong>${e.toolName}</strong>
|
|
2330
2454
|
${this.renderHeaderTarget(l)}
|
|
2331
2455
|
</div>
|
|
2332
2456
|
<div class="tool-meta">
|
|
2333
|
-
${
|
|
2457
|
+
${Fx(e)===void 0?null:g`<span>${Fx(e)}</span>`}
|
|
2334
2458
|
${a===void 0?null:g`<span class="diff-stats"><b class="added">+${a.added}</b><span>/</span><b class="removed">-${a.removed}</b></span>`}
|
|
2335
|
-
<span class="status-label">${
|
|
2459
|
+
<span class="status-label">${Hx(e.status)}</span>
|
|
2336
2460
|
</div>
|
|
2337
2461
|
</div>
|
|
2338
2462
|
|
|
@@ -2357,7 +2481,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2357
2481
|
`}
|
|
2358
2482
|
</details>
|
|
2359
2483
|
`}renderDiffBody(e,t,n){let r=e.split(`
|
|
2360
|
-
`),i=!this.showFullDiff&&r.length>
|
|
2484
|
+
`),i=!this.showFullDiff&&r.length>jx,a=i?r.slice(0,jx):r;return g`
|
|
2361
2485
|
<details class="diff-details" ?open=${this.diffOpen} @toggle=${e=>{this.onDiffToggle(e)}}>
|
|
2362
2486
|
<summary>
|
|
2363
2487
|
<span>${t}</span>
|
|
@@ -2368,14 +2492,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2368
2492
|
<span>${i?`Showing ${String(a.length)} of ${String(r.length)} lines`:`Full diff`}</span>
|
|
2369
2493
|
<button type="button" @click=${()=>{this.copyDiff(e)}}>${this.copied?`Copied`:`Copy diff`}</button>
|
|
2370
2494
|
</div>
|
|
2371
|
-
<pre class="diff" aria-label=${t}><code class="diff-content">${a.map(e=>g`<span class=${
|
|
2495
|
+
<pre class="diff" aria-label=${t}><code class="diff-content">${a.map(e=>g`<span class=${Rx(e)}>${e}</span>`)}</code></pre>
|
|
2372
2496
|
${i?g`
|
|
2373
2497
|
<button class="show-more" type="button" @click=${()=>{this.showFullDiff=!0}}>
|
|
2374
2498
|
Show all ${String(r.length)} diff lines
|
|
2375
2499
|
</button>
|
|
2376
2500
|
`:null}
|
|
2377
2501
|
</details>
|
|
2378
|
-
`}onDiffToggle(e){let t=e.currentTarget;t instanceof HTMLDetailsElement&&(this.diffOpen=t.open)}async copyDiff(e){if(!await
|
|
2502
|
+
`}onDiffToggle(e){let t=e.currentTarget;t instanceof HTMLDetailsElement&&(this.diffOpen=t.open)}async copyDiff(e){if(!await Wv(e)){this.copied=!1;return}this.copied=!0,window.setTimeout(()=>{this.copied=!1},1200)}static{this.styles=h`
|
|
2379
2503
|
:host { display: block; width: 100%; max-width: 100%; min-width: 0; color: var(--pi-text); }
|
|
2380
2504
|
.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); }
|
|
2381
2505
|
.tool-card.running, .tool-card.pending { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); }
|
|
@@ -2419,25 +2543,25 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2419
2543
|
.diff .added { background: color-mix(in srgb, var(--pi-success) 12%, transparent); }
|
|
2420
2544
|
.diff .removed { background: color-mix(in srgb, var(--pi-danger) 12%, transparent); }
|
|
2421
2545
|
.show-more { justify-self: start; }
|
|
2422
|
-
`}};B([x({attribute:!1})],
|
|
2423
|
-
`))
|
|
2546
|
+
`}};B([x({attribute:!1})],Mx.prototype,`execution`,void 0),B([S()],Mx.prototype,`showFullDiff`,void 0),B([S()],Mx.prototype,`copied`,void 0),B([S()],Mx.prototype,`diffOpen`,void 0),Mx=B([b(`tool-execution-view`)],Mx);function Nx(e,t){if(t!==void 0&&t!==``)return{label:`File`,text:t};let n=Gx(e.args,`command`);if(n!==void 0&&n!==``)return{label:`Command`,text:n};if(e.summary!==``)return{label:`Input`,text:e.summary}}function Px(e){return Gx(e,`path`)??Gx(e,`file_path`)}function Fx(e){if(e.toolName!==`edit`)return;let t=Wx(e.args,`edits`);if(Array.isArray(t))return`${String(t.length)} edit${t.length===1?``:`s`}`;if(typeof Wx(e.args,`oldText`)==`string`&&typeof Wx(e.args,`newText`)==`string`)return`1 edit`}function Ix(e){return Gx(e,`diff`)}function Lx(e){let t=0,n=0;for(let r of e.split(`
|
|
2547
|
+
`))zx(r)?t++:Bx(r)&&n++;return{added:t,removed:n}}function Rx(e){return zx(e)?`added`:Bx(e)?`removed`:e.startsWith(`@@`)?`hunk`:e.startsWith(`+++`)||e.startsWith(`---`)?`file`:e.startsWith(`diff `)||e.startsWith(`index `)?`meta`:`context`}function zx(e){return e.startsWith(`+`)&&!e.startsWith(`+++`)}function Bx(e){return e.startsWith(`-`)&&!e.startsWith(`---`)}function Vx(e){return e===`success`?`✓`:e===`error`?`✖`:e===`running`?`●`:`○`}function Hx(e){return e===`success`?`done`:e===`error`?`failed`:e===`running`?`running`:`pending`}function Ux(e){return typeof e==`object`&&!!e}function Wx(e,t){return Ux(e)?e[t]:void 0}function Gx(e,t){let n=Wx(e,t);return typeof n==`string`?n:void 0}var Kx=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),qx=new Intl.DateTimeFormat(void 0,{timeStyle:`short`});function Jx(e){return g`
|
|
2424
2548
|
<svg class=${`notification-icon notification-disclosure-icon${e?``:` expanded`}`} viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2425
2549
|
<path d="m9 18 6-6-6-6"></path>
|
|
2426
2550
|
</svg>
|
|
2427
|
-
`}function
|
|
2551
|
+
`}function Yx(){return g`
|
|
2428
2552
|
<svg class="notification-icon notification-close-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2429
2553
|
<path d="M6 6l12 12"></path>
|
|
2430
2554
|
<path d="M18 6 6 18"></path>
|
|
2431
2555
|
</svg>
|
|
2432
|
-
`}function
|
|
2433
|
-
`)}function
|
|
2556
|
+
`}function Xx(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`machineId`)==`string`&&typeof Reflect.get(e,`cwd`)==`string`&&typeof Reflect.get(e,`sessionId`)==`string`}function Zx(e){return Qx(e,0,100)}function Qx(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}function $x(e,t){return[e.length===0?void 0:{source:`client`,heading:`Queued until session starts`,detail:`Will send once the backend session is ready`,messages:e},t.length===0?void 0:{source:`server`,heading:`Queued messages`,detail:`${String(t.length)} pending`,messages:t}].filter(e=>e!==void 0)}function eS(e){return{src:`data:${e.mimeType};base64,${e.data}`,alt:`attached image`}}function tS(e){return e===void 0||e===``?`tool output`:`${e} output`}function nS(e){return`m:${String(e)}`}function rS(e){return`g:${String(e)}`}function iS(e){return`e:${String(e)}`}function aS(e){return`g:${String(e)}`}function oS(e){return e?`msg event-group live`:`msg event-group`}function sS(e){return e?`live events`:`events`}function cS(e,t,n){return e.source===`server`&&t&&n}function lS(e){return(e?.warnings??[]).map(e=>({severity:e.severity,severityClass:`session-warning ${e.severity}`,message:e.message,...e.source===void 0?{}:{source:e.source},...e.path===void 0?{}:{path:e.path},...e.dismiss===void 0?{}:{dismissId:e.dismiss.id}}))}function uS(e){return e>=50?`generation-rate very-fast`:e>=30?`generation-rate fast`:e>=15?`generation-rate moderate`:`generation-rate slow`}function dS(e){if(e===void 0)return{afterStatus:[],trailing:[]};let t=e.contextUsage,n=t?t.percent==null?`context ${Py(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${Py(t.contextWindow)}`:`context unknown`,r=e.generation;return{afterStatus:!e.isStreaming||r===void 0||!Number.isFinite(r.outputTokens)||r.outputTokens<=0?[]:[{label:r.estimated===!0?`Estimated received tokens`:`Received tokens`,text:`↓ ${Py(r.outputTokens)}`},...r.tokensPerSecond===void 0||!Number.isFinite(r.tokensPerSecond)||r.tokensPerSecond<=0?[]:[{label:r.estimated===!0?`Estimated generation speed`:`Generation speed`,text:`${r.tokensPerSecond.toFixed(1)} t/s`,className:uS(r.tokensPerSecond)}]],trailing:[{label:`Input tokens`,text:`↑${Py(e.tokens.input)}`},{label:`Output tokens`,text:`↓${Py(e.tokens.output)}`},{label:`Context usage`,text:n},{label:`Session cost`,text:Fy(e.cost)},...e.pendingMessageCount>0?[{label:`Queued messages`,text:`${String(e.pendingMessageCount)} queued`}]:[]]}}function fS(e,t){if(!Number.isInteger(e)||e<=0)return;let n=`${String(e)} ${e===1?`warning`:`warnings`}`;return{countText:String(e),accessibleLabel:t?`Minimise ${n}`:`Show ${n} in the warning area`}}function pS(e){let t=e.meta?.timestamp,n=[t===void 0?void 0:gS(t),_S(e)].filter(e=>e!==void 0&&e!==``);return n.length===0?`No Pi message metadata available`:n.join(` · `)}function mS(e,t){return!t.enabled||t.busy||e.role!==`user`?{}:{...e.previousAssistantEntryId===void 0?{}:{editFromHereEntryId:e.previousAssistantEntryId},...e.canFork===!0&&e.entryId!==void 0?{forkEntryId:e.entryId}:{}}}function hS(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2557
|
+
`)}function gS(e){let t=new Date(e);if(Number.isFinite(t.getTime()))return Kx.format(t)}function _S(e){let t=e.meta?.model;if(t===void 0)return;let n=t.responseId??t.id;return n===void 0||n===``?t.provider:t.provider!==void 0&&t.provider!==``?`${t.provider}/${n}`:n}var G=class extends y{constructor(...e){super(...e),this.messages=[],this.sessionId=``,this.messageStart=0,this.messageEnd=0,this.messageTotal=0,this.hasMore=!1,this.loadingMore=!1,this.isSendingPrompt=!1,this.isCompacting=!1,this.pendingMessageCount=0,this.clientQueuedMessages=[],this.warningCount=0,this.warningsExpanded=!1,this.canClearServerQueue=!1,this.canMessageActions=!1,this.warningsVisible=!0,this.pinnedToBottom=!0,this.zoomedImage=void 0,this.collapsedNotificationTargetKeys=new Set,this.disclosures=new Nv,this.scrollController=new hy,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.sessionInfoOpen=!1,this._minimapMarkers=[],this._minimapViewport={scrollRatio:0,viewportRatio:1,visible:!1},this._minimapLoadedPercent=100,this.onViewportResize=()=>{this.pinnedToBottom?this.scrollToBottom():this.lastClientHeight=this.chat?.clientHeight??0},this.onImageLoad=()=>{this.pinnedToBottom&&this.scrollToBottom()},this.openImageZoom=(e,t)=>{this.zoomedImage={src:e,alt:t}},this.closeImageZoom=()=>{this.zoomedImage!==void 0&&(this.zoomedImage=void 0)},this.onImageZoomDialogClick=e=>{e.target===this.imageZoomDialog&&this.closeImageZoom()},this.onPageHide=()=>{this.saveScrollPosition()},this.handleClearServerQueue=()=>{this.onClearServerQueue?.()},this.handleToggleWarnings=()=>{this.onToggleWarnings?.()},this.handleUsageToggle=()=>{this.sessionInfoOpen=!this.sessionInfoOpen},this.handleUsageKeydown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.sessionInfoOpen=!this.sessionInfoOpen)},this.closeSessionInfoPopover=()=>{this.sessionInfoOpen&&(this.sessionInfoOpen=!1,this.removePopoverOutsideListener(),this.requestUpdate())},this.handlePopoverKeydown=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.closeSessionInfoPopover(),this.focusUsageToggle())},this.onPopoverGlobalClick=e=>{this.handlePopoverClickOutside(e)},this.popoverGlobalListenerAttached=!1}focusUsageToggle(){this.renderRoot!==void 0&&this.renderRoot.querySelector(`.usage-toggle`)?.focus()}handlePopoverClickOutside(e){let t=this.renderRoot.querySelector(`.session-info-popover`),n=this.renderRoot.querySelector(`.usage-toggle`);if(t===null||n===null)return;let r=e.target;r instanceof Node&&!t.contains(r)&&!n.contains(r)&&this.closeSessionInfoPopover()}ensurePopoverOutsideListener(){this.popoverGlobalListenerAttached||typeof window>`u`||(this.popoverGlobalListenerAttached=!0,window.addEventListener(`click`,this.onPopoverGlobalClick,!0))}removePopoverOutsideListener(){this.popoverGlobalListenerAttached&&(this.popoverGlobalListenerAttached=!1,!(typeof window>`u`)&&window.removeEventListener(`click`,this.onPopoverGlobalClick,!0))}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.onViewportResize),window.addEventListener(`pagehide`,this.onPageHide),window.visualViewport?.addEventListener(`resize`,this.onViewportResize),this._setupResizeObserver()}firstUpdated(){this.lastClientHeight=this.chat?.clientHeight??0}_setupResizeObserver(){if(this._resizeObserver!==void 0)return;let e=this.chat;e&&(this._resizeObserver=new ResizeObserver(()=>{this._requestMinimapMeasure()}),this._resizeObserver.observe(e))}disconnectedCallback(){this.removePopoverOutsideListener(),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),this._minimapMeasureTimer!==void 0&&(clearTimeout(this._minimapMeasureTimer),this._minimapMeasureTimer=void 0),this._resizeObserver!==void 0&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),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.pendingNotificationFocus=void 0,this.retainedEmptyNotificationTrayTargetKey=void 0,this.sessionInfoOpen=!1,this.scrollController.clearScheduledSave(),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0,this._minimapMarkers=[],this._minimapViewport={scrollRatio:0,viewportRatio:1,visible:!1},this._minimapLoadedPercent=100,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(`notificationInbox`)&&this.notificationTargetChanged(e.get(`notificationInbox`))&&(this.pendingNotificationFocus=void 0,this.retainedEmptyNotificationTrayTargetKey=void 0),e.has(`messages`)&&(this.pinnedToBottom=this.pinnedToBottom&&(this.didChatHeightChange()||this.isNearBottom()))}update(e){let 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(),this._requestMinimapMeasure()),e.has(`messages`)&&!e.has(`sessionId`)&&this._updateMinimapViewport(),(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(),e.has(`notificationInbox`)&&this.pendingNotificationFocus!==void 0&&this.focusPendingNotificationTarget(),e.has(`zoomedImage`)&&this.syncImageZoomDialog(),this.syncPopoverOutsideListener()}syncPopoverOutsideListener(){this.sessionInfoOpen?this.ensurePopoverOutsideListener():this.removePopoverOutsideListener()}syncImageZoomDialog(){let e=this.imageZoomDialog;e!==void 0&&(this.zoomedImage!==void 0&&!e.open?e.showModal():this.zoomedImage===void 0&&e.open&&e.close())}notificationTargetChanged(e){let t=this.notificationInbox;return!Xx(e)||t===void 0?e!==t:hd(e)!==hd(t)}render(){let e=this.groupedMessages();return g`
|
|
2434
2558
|
${this.renderTopNotices()}
|
|
2435
2559
|
${this.renderNotificationLiveRegions()}
|
|
2436
2560
|
<div class="chat-wrap" style=${this._minimapViewport.visible?`--pi-minimap-right:36px`:``}>
|
|
2437
2561
|
${this.renderConversationRail()}
|
|
2438
2562
|
<div class="chat" @scroll=${()=>{this.onScroll()}} @wheel=${e=>{this.onWheel(e)}} @touchstart=${e=>{this.onTouchStart(e)}} @touchmove=${e=>{this.onTouchMove(e)}}>
|
|
2439
2563
|
${this.renderHistoryBoundary()}
|
|
2440
|
-
${
|
|
2564
|
+
${P_(e,e=>e.kind===`group`?this.groupRenderKey(e.startIndex):this.messageAnchorKey(e.index),(t,n)=>t.kind===`group`?this.renderMessageGroup(t.messages,t.startIndex,t.endIndex,this.isLiveTailGroup(e,n)):t.kind===`tool-image`?this.renderToolImageOutput(t.message,t.index,t.toolName):this.renderMessage(t.message,t.index))}
|
|
2441
2565
|
${this.renderQueuedMessages()}
|
|
2442
2566
|
${this.renderSessionActivity()}
|
|
2443
2567
|
</div>
|
|
@@ -2465,7 +2589,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2465
2589
|
aria-expanded=${String(!a)}
|
|
2466
2590
|
aria-controls="session-notification-list"
|
|
2467
2591
|
@click=${()=>{this.toggleNotificationTray(e,a)}}
|
|
2468
|
-
>${
|
|
2592
|
+
>${Jx(a)}</button>
|
|
2469
2593
|
</div>
|
|
2470
2594
|
</header>
|
|
2471
2595
|
<div class="notification-list" id="session-notification-list" ?hidden=${a}>
|
|
@@ -2477,7 +2601,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2477
2601
|
<div class="notification-metadata">
|
|
2478
2602
|
<strong class="notification-severity">${n}</strong>
|
|
2479
2603
|
<span aria-hidden="true">·</span>
|
|
2480
|
-
<time datetime=${t.receivedAt}>${
|
|
2604
|
+
<time datetime=${t.receivedAt}>${qx.format(new Date(t.receivedAt))}</time>
|
|
2481
2605
|
</div>
|
|
2482
2606
|
<p class="notification-message" dir="auto">${t.message}</p>
|
|
2483
2607
|
${r===void 0?null:g`<p class="notification-truncated">${r}</p>`}
|
|
@@ -2488,15 +2612,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2488
2612
|
title="Dismiss notification"
|
|
2489
2613
|
?disabled=${e.pendingDismissedIds.has(t.id)||e.dismissAllPending||this.onDismissNotification===void 0}
|
|
2490
2614
|
@click=${()=>{this.dismissNotification(t.id)}}
|
|
2491
|
-
>${
|
|
2615
|
+
>${Yx()}</button>
|
|
2492
2616
|
</article>
|
|
2493
2617
|
`})}
|
|
2494
2618
|
</div>
|
|
2495
2619
|
</section>
|
|
2496
2620
|
`}renderNotificationLiveRegions(){let e=this.notificationInbox?.sessionId===this.sessionId?this.notificationInbox.announcements:[],t=e.filter(e=>e.severity!==`error`),n=e.filter(e=>e.severity===`error`);return g`
|
|
2497
|
-
<div class="visually-hidden notification-live" aria-live="polite" aria-atomic="false">${
|
|
2498
|
-
<div class="visually-hidden notification-live" aria-live="assertive" aria-atomic="false">${
|
|
2499
|
-
`}toggleNotificationTray(e,t){this.collapsedNotificationTargetKeys=_d(this.collapsedNotificationTargetKeys,e,!t)}dismissNotification(e){let t=this.notificationInbox;if(t===void 0||this.onDismissNotification===void 0)return;let n=md(t.notifications,e),r=hd(t);this.pendingNotificationFocus={chatKey:r,focusTarget:n},n.kind===`header`&&(this.retainedEmptyNotificationTrayTargetKey=r),this.onDismissNotification(e)}dismissAllNotifications(){let e=this.notificationInbox;if(e===void 0||this.onDismissAllNotifications===void 0)return;let t=hd(e);this.pendingNotificationFocus={chatKey:t,focusTarget:{kind:`header`}},this.retainedEmptyNotificationTrayTargetKey=t,this.onDismissAllNotifications()}releaseEmptyNotificationTray(e){let t=e.currentTarget,n=e.relatedTarget;if(t instanceof HTMLElement&&n instanceof Node&&t.contains(n)||this.pendingNotificationFocus!==void 0)return;let r=this.notificationInbox;r!==void 0&&this.retainedEmptyNotificationTrayTargetKey===hd(r)&&dd(r)===0&&(this.retainedEmptyNotificationTrayTargetKey=void 0)}focusPendingNotificationTarget(){let e=this.pendingNotificationFocus;this.pendingNotificationFocus=void 0;let t=this.notificationInbox;if(e===void 0||t===void 0||hd(t)!==e.chatKey)return;let n=e.focusTarget;if(n.kind===`header`){this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus();return}let r=Array.from(this.renderRoot.querySelectorAll(`[data-notification-id]`)).find(e=>e.dataset.notificationId===n.notificationId);if(r!==void 0){r.focus();return}dd(t)===0&&(this.retainedEmptyNotificationTrayTargetKey=e.chatKey),this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus()}renderWarnings(){let e=
|
|
2621
|
+
<div class="visually-hidden notification-live" aria-live="polite" aria-atomic="false">${P_(t,e=>e.id,e=>g`<span data-announcement-id=${e.id}>${ud(e)}</span>`)}</div>
|
|
2622
|
+
<div class="visually-hidden notification-live" aria-live="assertive" aria-atomic="false">${P_(n,e=>e.id,e=>g`<span data-announcement-id=${e.id}>${ud(e)}</span>`)}</div>
|
|
2623
|
+
`}toggleNotificationTray(e,t){this.collapsedNotificationTargetKeys=_d(this.collapsedNotificationTargetKeys,e,!t)}dismissNotification(e){let t=this.notificationInbox;if(t===void 0||this.onDismissNotification===void 0)return;let n=md(t.notifications,e),r=hd(t);this.pendingNotificationFocus={chatKey:r,focusTarget:n},n.kind===`header`&&(this.retainedEmptyNotificationTrayTargetKey=r),this.onDismissNotification(e)}dismissAllNotifications(){let e=this.notificationInbox;if(e===void 0||this.onDismissAllNotifications===void 0)return;let t=hd(e);this.pendingNotificationFocus={chatKey:t,focusTarget:{kind:`header`}},this.retainedEmptyNotificationTrayTargetKey=t,this.onDismissAllNotifications()}releaseEmptyNotificationTray(e){let t=e.currentTarget,n=e.relatedTarget;if(t instanceof HTMLElement&&n instanceof Node&&t.contains(n)||this.pendingNotificationFocus!==void 0)return;let r=this.notificationInbox;r!==void 0&&this.retainedEmptyNotificationTrayTargetKey===hd(r)&&dd(r)===0&&(this.retainedEmptyNotificationTrayTargetKey=void 0)}focusPendingNotificationTarget(){let e=this.pendingNotificationFocus;this.pendingNotificationFocus=void 0;let t=this.notificationInbox;if(e===void 0||t===void 0||hd(t)!==e.chatKey)return;let n=e.focusTarget;if(n.kind===`header`){this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus();return}let r=Array.from(this.renderRoot.querySelectorAll(`[data-notification-id]`)).find(e=>e.dataset.notificationId===n.notificationId);if(r!==void 0){r.focus();return}dd(t)===0&&(this.retainedEmptyNotificationTrayTargetKey=e.chatKey),this.renderRoot.querySelector(`[data-notification-focus='header']`)?.focus()}renderWarnings(){let e=lS(this.status);return!this.warningsVisible||e.length===0?null:g`
|
|
2500
2624
|
<aside class="session-warnings" role="alert" aria-live="polite">
|
|
2501
2625
|
${e.map(e=>{let t=e.dismissId;return g`
|
|
2502
2626
|
<div class=${e.severityClass}>
|
|
@@ -2520,7 +2644,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2520
2644
|
</div>
|
|
2521
2645
|
`})}
|
|
2522
2646
|
</aside>
|
|
2523
|
-
`}renderSessionInfoPopover(){if(!this.sessionInfoOpen)return null;let e=this.status;if(e===void 0)return null;let t=this.messages.length>0?
|
|
2647
|
+
`}renderSessionInfoPopover(){if(!this.sessionInfoOpen)return null;let e=this.status;if(e===void 0)return null;let t=this.messages.length>0?By(this.messages):void 0,n=Vy(e,this.sessionInfo,t);return g`
|
|
2524
2648
|
<section
|
|
2525
2649
|
class="session-info-popover"
|
|
2526
2650
|
id=${`session-info-popover-${this.sessionId}`}
|
|
@@ -2570,14 +2694,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2570
2694
|
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />
|
|
2571
2695
|
</svg>
|
|
2572
2696
|
</button>
|
|
2573
|
-
`}async copySessionValue(e){await
|
|
2697
|
+
`}async copySessionValue(e){await Wv(e)}renderImageZoom(){return g`
|
|
2574
2698
|
<dialog class="image-zoom" @click=${this.onImageZoomDialogClick} @close=${this.closeImageZoom} @cancel=${this.closeImageZoom}>
|
|
2575
2699
|
${this.zoomedImage===void 0?null:g`
|
|
2576
2700
|
<button type="button" class="image-zoom-close" aria-label="Close image" @click=${this.closeImageZoom}>×</button>
|
|
2577
2701
|
<img class="image-zoom-full" src=${this.zoomedImage.src} alt=${this.zoomedImage.alt} />
|
|
2578
2702
|
`}
|
|
2579
2703
|
</dialog>
|
|
2580
|
-
`}groupedMessages(){return this.groupedMessagesInput===this.messages&&this.groupedMessagesStart===this.messageStart?this.groupedMessagesCache:(this.groupedMessagesInput=this.messages,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=
|
|
2704
|
+
`}groupedMessages(){return this.groupedMessagesInput===this.messages&&this.groupedMessagesStart===this.messageStart?this.groupedMessagesCache:(this.groupedMessagesInput=this.messages,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=zv(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 this.renderActivityDockContent(`Sending your message…`,!0);let e=this.activityState();return e===void 0?null:this.renderActivityDockContent(this.activityText(e),e!==`idle`||this.activity?.phase===`active`)}renderActivityDockContent(e,t){let n=dS(this.status),r=fS(this.warningCount,this.warningsExpanded),i=n.trailing.length>0,a=this.status?zy(this.status):``,o=i?`session-info-popover-${this.sessionId}`:void 0;return g`
|
|
2581
2705
|
<div class=${t?`activity-dock active`:`activity-dock`}>
|
|
2582
2706
|
${r===void 0||this.onToggleWarnings===void 0?null:g`
|
|
2583
2707
|
<button
|
|
@@ -2620,7 +2744,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2620
2744
|
`:null}
|
|
2621
2745
|
${this.renderSessionInfoPopover()}
|
|
2622
2746
|
</div>
|
|
2623
|
-
`}renderActivityMetrics(e){return e.map(e=>g`<span class=${e.className===void 0?`activity-metric`:`activity-metric ${e.className}`} title=${e.label}>${e.text}</span>`)}renderQueuedMessages(){let e=this.status?.queuedMessages??[];return g`${
|
|
2747
|
+
`}renderActivityMetrics(e){return e.map(e=>g`<span class=${e.className===void 0?`activity-metric`:`activity-metric ${e.className}`} title=${e.label}>${e.text}</span>`)}renderQueuedMessages(){let e=this.status?.queuedMessages??[];return g`${$x(this.clientQueuedMessages,e).map(e=>this.renderQueuedMessageList(e))}`}renderQueuedMessageList(e){let t=cS(e,this.canClearServerQueue,this.onClearServerQueue!==void 0);return g`
|
|
2624
2748
|
<aside class="queued-messages" aria-live="polite">
|
|
2625
2749
|
<div class="queued-header">
|
|
2626
2750
|
<div class="queued-heading">
|
|
@@ -2644,7 +2768,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2644
2768
|
<span>The agent is summarizing earlier context. New prompts will be queued until compaction finishes.</span>
|
|
2645
2769
|
${this.pendingMessageCount>0?g`<small>${this.pendingMessageCount} queued ${this.pendingMessageCount===1?`message`:`messages`}</small>`:null}
|
|
2646
2770
|
</aside>
|
|
2647
|
-
`:null}activityState(){let 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){let 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(){return!this.messages.length||this.messageTotal<=0?null:(this._minimapLoadedPercent=this.hasMore?
|
|
2771
|
+
`:null}activityState(){let 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){let 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(){return!this.messages.length||this.messageTotal<=0?null:(this._minimapLoadedPercent=this.hasMore?Zx(this.messages.length/this.conversationDisplayTotal()*100):100,g`
|
|
2648
2772
|
<chat-minimap
|
|
2649
2773
|
.scrollRatio=${this._minimapViewport.scrollRatio}
|
|
2650
2774
|
.viewportRatio=${this._minimapViewport.viewportRatio}
|
|
@@ -2653,7 +2777,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2653
2777
|
.markers=${this._minimapMarkers}
|
|
2654
2778
|
@minimap-scroll-to=${e=>{this._onMinimapScrollTo(e)}}
|
|
2655
2779
|
></chat-minimap>
|
|
2656
|
-
`)}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;let t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart;return
|
|
2780
|
+
`)}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;let t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart;return Zx(Qx(this.currentConversationIndex??t,0,e-1)/(e-1)*100)}renderHistoryBoundary(){let e=this.historyRangeLabel();return this.loadingMore?g`<div class="history-boundary"><span>Loading earlier messages…</span>${e}</div>`:this.hasMore?g`
|
|
2657
2781
|
<div class="history-boundary">
|
|
2658
2782
|
<button type="button" class="history-load-button" ?disabled=${this.loadMoreRequested} @click=${()=>{this.requestLoadMore()}}>Load earlier messages</button>
|
|
2659
2783
|
<span>Scroll up to load earlier messages</span>
|
|
@@ -2665,7 +2789,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2665
2789
|
${n?null:this.renderMessageHeader(e,String(t))}
|
|
2666
2790
|
${e.parts.map(t=>this.renderPart(t,e))}
|
|
2667
2791
|
</article>
|
|
2668
|
-
`}renderToolImageOutput(e,t,n){let r=
|
|
2792
|
+
`}renderToolImageOutput(e,t,n){let r=tS(n);return g`
|
|
2669
2793
|
${this.renderScrollMarker(this.messageScrollMarkerId(t))}
|
|
2670
2794
|
<article class="msg tool-image-output" data-index=${t} data-scroll-anchor-id=${this.messageAnchorKey(t)}>
|
|
2671
2795
|
${this.renderMessageHeader(e,String(t),r)}
|
|
@@ -2673,10 +2797,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2673
2797
|
</article>
|
|
2674
2798
|
`}isToolExecutionOnlyMessage(e){return e.role===`tool`&&e.parts.length>0&&e.parts.every(e=>e.type===`toolExecution`)}renderMessageGroup(e,t,n,r){let i=this.groupDisclosureKey(t,n,r),a=this.disclosures.isOpen(i,r);return g`
|
|
2675
2799
|
${this.renderScrollMarker(this.groupScrollMarkerId(n))}
|
|
2676
|
-
<details class=${
|
|
2800
|
+
<details class=${oS(r)} data-index=${t} data-scroll-anchor-id=${this.groupAnchorKey(t)} ?open=${a} @toggle=${e=>{this.onGroupToggle(i,e,r)}}>
|
|
2677
2801
|
<summary>
|
|
2678
|
-
<b class="label">${
|
|
2679
|
-
<span>${
|
|
2802
|
+
<b class="label">${sS(r)}</b>
|
|
2803
|
+
<span>${Bv(e)}</span>
|
|
2680
2804
|
</summary>
|
|
2681
2805
|
${a?this.renderMessageGroupBody(e,t):null}
|
|
2682
2806
|
</details>
|
|
@@ -2697,7 +2821,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2697
2821
|
<span class=${i?`msg-meta expanded`:`msg-meta`} role="button" tabindex="0" title=${r} aria-label=${r} aria-expanded=${String(i)} @click=${()=>{this.expandedMetaKey=i?void 0:t}} @keydown=${e=>{this.onMetaKeydown(e,t,i)}}>${r}</span>
|
|
2698
2822
|
</div>
|
|
2699
2823
|
</div>
|
|
2700
|
-
`}renderMessageActions(e,t){let n=this.isCopyableMessage(e),r=
|
|
2824
|
+
`}renderMessageActions(e,t){let n=this.isCopyableMessage(e),r=mS(e,{enabled:this.canMessageActions,busy:this.messageActionsBusy()}),i=this.onEditFromHere===void 0?void 0:r.editFromHereEntryId,a=this.onForkFromHere===void 0?void 0:r.forkEntryId;if(!n&&i===void 0&&a===void 0)return null;let o=this.copiedMessageKey===t,s=a!==void 0&&this.forkingEntryId===a;return g`
|
|
2701
2825
|
<div class=${`msg-actions${s?` forking`:``}`} aria-label="Message actions">
|
|
2702
2826
|
${n?g`
|
|
2703
2827
|
<button type="button" class="msg-action" title=${o?`Copied`:`Copy message`} aria-label=${`${o?`Copied`:`Copy`} ${e.role} message`} @click=${n=>{this.copyMessage(e,t,n)}}>
|
|
@@ -2705,7 +2829,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2705
2829
|
</button>
|
|
2706
2830
|
`:null}
|
|
2707
2831
|
${i===void 0?null:g`
|
|
2708
|
-
<button type="button" class="msg-action msg-history-action" data-message-action="edit-from-here" title="Edit from here — branches within this session" @click=${()=>{this.editFromHere(i,
|
|
2832
|
+
<button type="button" class="msg-action msg-history-action" data-message-action="edit-from-here" title="Edit from here — branches within this session" @click=${()=>{this.editFromHere(i,hS(e))}}>
|
|
2709
2833
|
<svg class="msg-history-action-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
2710
2834
|
<polyline points="15 10 20 15 15 20"></polyline>
|
|
2711
2835
|
<path d="M4 4v7a4 4 0 0 0 4 4h12"></path>
|
|
@@ -2727,7 +2851,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2727
2851
|
</div>
|
|
2728
2852
|
`}messageActionsBusy(){return this.isSendingPrompt||this.isCompacting||this.status?.isStreaming===!0||this.status?.isBashRunning===!0||this.status?.isCompacting===!0||(this.status?.pendingMessageCount??this.pendingMessageCount)>0}async editFromHere(e,t){await this.onEditFromHere?.(e,t)}async forkFromHere(e){if(this.forkingEntryId===void 0){this.forkingEntryId=e;try{await this.onForkFromHere?.(e)}finally{this.forkingEntryId===e&&(this.forkingEntryId=void 0)}}}onMetaKeydown(e,t,n){e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),this.expandedMetaKey=n?void 0:t)}isCopyableMessage(e){return(e.role===`user`||e.role===`assistant`)&&this.messageCopyText(e)!==``}messageCopyText(e){let t=this.messageCopyTextCache.get(e);if(t!==void 0)return t;let n=e.parts.filter(e=>e.type===`text`).map(e=>e.text.trim()).filter(e=>e!==``).join(`
|
|
2729
2853
|
|
|
2730
|
-
`);return this.messageCopyTextCache.set(e,n),n}async copyMessage(e,t,n){n.stopPropagation(),await
|
|
2854
|
+
`);return this.messageCopyTextCache.set(e,n),n}async copyMessage(e,t,n){n.stopPropagation(),await Wv(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}messageMetaLabel(e){let t=this.messageMetaCache.get(e);if(t!==void 0)return t;let n=pS(e);return this.messageMetaCache.set(e,n),n}renderPart(e,t){if(e.type===`text`&&t?.role===`bash`)return g`<pre class="part shell-output">${e.text}</pre>`;if(e.type===`text`)return g`<formatted-text class="part" .text=${e.text}></formatted-text>`;if(e.type===`thinking`)return g`<details class="part"><summary>thinking</summary><formatted-text .text=${e.text}></formatted-text></details>`;if(e.type===`skillInvocation`)return g`
|
|
2731
2855
|
<details class="part skill-invocation">
|
|
2732
2856
|
<summary><b>[skill]</b> ${e.name}</summary>
|
|
2733
2857
|
<small>${e.location}</small>
|
|
@@ -2738,58 +2862,58 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2738
2862
|
<strong>Loaded ${e.name}</strong>
|
|
2739
2863
|
<small>read ${e.path}</small>
|
|
2740
2864
|
</div>
|
|
2741
|
-
`;if(e.type===`image`){let{src:t,alt:n}=
|
|
2865
|
+
`;if(e.type===`image`){let{src:t,alt:n}=eS(e);return g`<img class="part chat-image" src=${t} alt=${n} loading="lazy" role="button" tabindex="0" title="Click to enlarge" @load=${this.onImageLoad} @click=${()=>{this.openImageZoom(t,n)}} @keydown=${e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.openImageZoom(t,n))}} />`}return e.type===`toolCall`?g`<div class="part tool-line">▶ ${e.toolName}<span class="summary">${e.summary}</span></div>`:e.type===`toolExecution`?g`<tool-execution-view class="part" .execution=${e}></tool-execution-view>`:e.type===`toolResult`?g`
|
|
2742
2866
|
<details class="part" ?open=${e.isError}>
|
|
2743
2867
|
<summary>${e.isError?`✖`:`✓`} ${e.toolName} result</summary>
|
|
2744
2868
|
<formatted-text .text=${e.text}></formatted-text>
|
|
2745
2869
|
</details>
|
|
2746
|
-
`:null}onGroupToggle(e,t,n){let r=t.currentTarget;r instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,r.open,n)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this._updateMinimapViewport(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){let t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){let e=this.chat;if(!e)return;let t=this.didChatHeightChange(),n=this.pinnedToBottom,r=e.scrollTop<this.lastScrollTop;if(t&&n){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:r?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){let e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){let 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;let e=this.chat;e&&ty({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(){let e=this.chat;return!e||hy(e)}isAtBottom(){let e=this.chat;return!e||my(e)<2}canScrollUp(){let e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;let e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}restoreScrollPosition(){let e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{let t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){let 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(()=>{let n=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,n)})}))}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;let n=this.chat;n===void 0||!this.hasMore||this.loadingMore||(n.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore}updatePinnedToBottomAfterRestore(e){e===`bottom`?this.pinnedToBottom=!0:e===`restored`&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){let e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){let e=this.chat;if(e)return qv(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;let t=this.prependRestoreToken+1;this.prependRestoreToken=t;let n=0,r=()=>{let i=this.chat;if(!(!i||t!==this.prependRestoreToken)){if(Jv(i,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=i.scrollTop,n+=1,n<30){requestAnimationFrame(r);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};r()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){let e=this.sessionId;this.scrollController.scheduleSave(e,e=>{this.sessionId===e&&this.saveScrollPosition(e)})}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}let e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),n=Number(t?.dataset.index);if(Number.isFinite(n)){this.currentConversationIndex=qx(n,0,Math.max(0,e-1));return}this.currentConversationIndex=qx(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(){let e=this.chat;if(e!==void 0)return vy(e,Array.from(this.renderRoot.querySelectorAll(`article.msg`)))??vy(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,n){return n?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return Zx(e)}groupRenderKey(e){return Qx(e)}groupAnchorKey(e){return Qx(e)}eventAnchorKey(e){return $x(e)}messageScrollMarkerId(e){return Zx(e)}groupScrollMarkerId(e){return eS(e)}_updateMinimapViewport(){let e=this.chat;e&&(this._minimapViewport=xy({scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,scrollTop:e.scrollTop}),this._minimapLoadedPercent=this.hasMore?Kx(this.messages.length/this.conversationDisplayTotal()*100):100)}_requestMinimapMeasure(){this._minimapMeasureTimer===void 0&&(this._minimapMeasureTimer=setTimeout(()=>{this._minimapMeasureTimer=void 0,this._measureMinimapMarkers(),this._updateMinimapViewport()},150))}_measureMinimapMarkers(){let e=this.chat;if(!e||!this.messages.length){this._minimapMarkers=[];return}let t=e.getBoundingClientRect(),n=e.scrollHeight;if(n<=0){this._minimapMarkers=[];return}let r=this.renderRoot.querySelectorAll(`article.msg.user, article.msg.assistant`),i=[];for(let a of r){let r=a.dataset.index;if(r===void 0)continue;let o=Number(r);if(!Number.isFinite(o))continue;let s=o-this.messageStart;if(s<0||s>=this.messages.length)continue;let c=this.messages[s];if(c===void 0)continue;let l=this._minimapMessagePreview(c);if(!l)continue;let u=wy(a.getBoundingClientRect().top,t.top,e.scrollTop,n);if(c.role!==`user`&&c.role!==`assistant`)continue;let d=c.role;i.push({topRatio:u,role:d,preview:l})}this._minimapMarkers=i}_minimapMessagePreview(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text.trim()).filter(e=>e!==``).join(` `).slice(0,200)}_onMinimapScrollTo(e){let t=Oy(e.detail);if(t===void 0)return;let n=this.chat;if(!n)return;let r=n.scrollHeight-n.clientHeight;r<=0||(n.scrollTop=Sy(t/(1-this._minimapViewport.viewportRatio))*r,this.pinnedToBottom=hy(n))}static{this.styles=Jp}};B([x({attribute:!1})],G.prototype,`messages`,void 0),B([x()],G.prototype,`sessionId`,void 0),B([x({type:Number})],G.prototype,`messageStart`,void 0),B([x({type:Number})],G.prototype,`messageEnd`,void 0),B([x({type:Number})],G.prototype,`messageTotal`,void 0),B([x({type:Boolean})],G.prototype,`hasMore`,void 0),B([x({type:Boolean})],G.prototype,`loadingMore`,void 0),B([x({type:Boolean})],G.prototype,`isSendingPrompt`,void 0),B([x({type:Boolean})],G.prototype,`isCompacting`,void 0),B([x({type:Number})],G.prototype,`pendingMessageCount`,void 0),B([x({attribute:!1})],G.prototype,`clientQueuedMessages`,void 0),B([x({attribute:!1})],G.prototype,`status`,void 0),B([x({type:Number})],G.prototype,`warningCount`,void 0),B([x({type:Boolean})],G.prototype,`warningsExpanded`,void 0),B([x({attribute:!1})],G.prototype,`onToggleWarnings`,void 0),B([x({attribute:!1})],G.prototype,`activity`,void 0),B([x({attribute:!1})],G.prototype,`sessionInfo`,void 0),B([x({attribute:!1})],G.prototype,`notificationInbox`,void 0),B([x({type:Boolean})],G.prototype,`canClearServerQueue`,void 0),B([x({type:Boolean})],G.prototype,`canMessageActions`,void 0),B([x({attribute:!1})],G.prototype,`onEditFromHere`,void 0),B([x({attribute:!1})],G.prototype,`onForkFromHere`,void 0),B([x({attribute:!1})],G.prototype,`onClearServerQueue`,void 0),B([x({attribute:!1})],G.prototype,`onDismissWarning`,void 0),B([x({attribute:!1})],G.prototype,`onDismissNotification`,void 0),B([x({attribute:!1})],G.prototype,`onDismissAllNotifications`,void 0),B([x({type:Boolean})],G.prototype,`warningsVisible`,void 0),B([x({attribute:!1})],G.prototype,`onLoadMore`,void 0),B([C(`.chat`)],G.prototype,`chat`,void 0),B([C(`dialog.image-zoom`)],G.prototype,`imageZoomDialog`,void 0),B([S()],G.prototype,`pinnedToBottom`,void 0),B([S()],G.prototype,`zoomedImage`,void 0),B([S()],G.prototype,`expandedMetaKey`,void 0),B([S()],G.prototype,`copiedMessageKey`,void 0),B([S()],G.prototype,`forkingEntryId`,void 0),B([S()],G.prototype,`currentConversationIndex`,void 0),B([S()],G.prototype,`collapsedNotificationTargetKeys`,void 0),B([S()],G.prototype,`retainedEmptyNotificationTrayTargetKey`,void 0),B([S()],G.prototype,`loadMoreRequested`,void 0),B([S()],G.prototype,`sessionInfoOpen`,void 0),B([S()],G.prototype,`_minimapMarkers`,void 0),B([S()],G.prototype,`_minimapViewport`,void 0),G=B([b(`chat-view`)],G);var pS=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function mS(e){return typeof e==`string`&&pS.has(e)}function hS(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`}}var gS=`application/octet-stream`,_S=`Failed to read an attachment.`;async function vS(e,t){let n=[],r;for(let i of e)try{let e=await t(i);n.push(SS(i,e))}catch{r=_S}return{attachments:n,...r===void 0?{}:{error:r}}}function yS(e){return e.kind===`image`&&mS(e.mimeType)}function bS(e){return e.every(e=>yS(e))}function xS(e,t){return bS(t)?e:`folder`}function SS(e,t){return mS(e.type)?{kind:`image`,name:wS(e),mimeType:e.type,data:t,size:e.size}:{kind:`file`,name:wS(e),mimeType:CS(e),data:t,size:e.size}}function CS(e){let t=e.type.trim();return t===``?gS:t}function wS(e){return e.name===``?mS(e.type)?`pasted-image.${hS(e.type)}`:`pasted-file.bin`:e.name}var TS=`pi-webui:attachment-delivery`;function ES(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function DS(e=ES()){try{return e?.getItem(TS)===`folder`?`folder`:`inline`}catch{return`inline`}}function OS(e,t=ES()){try{t?.setItem(TS,e)}catch{}}var kS=`(pointer: coarse), (max-width: 760px)`,AS=`pi-webui.promptEnterPreference`;function jS(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(kS):void 0}function MS(e){return e===`send`||e===`newline`?e:`auto`}function NS(e=RS()){if(e===void 0)return`auto`;try{return MS(e.getItem(AS))}catch{return`auto`}}function PS(e,t=RS()){if(t!==void 0)try{t.setItem(AS,e)}catch{}}function FS(e=jS(),t=NS()){return t===`send`||t!==`newline`&&e?.matches!==!0}function IS(e,t,n=jS()){return e?n?.matches!==!0||t:!1}function LS(e,t=jS(),n=NS()){let r=FS(t,n);return e?!r:r}function RS(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}function zS(){return _`
|
|
2870
|
+
`:null}onGroupToggle(e,t,n){let r=t.currentTarget;r instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,r.open,n)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this._updateMinimapViewport(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){let t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){let e=this.chat;if(!e)return;let t=this.didChatHeightChange(),n=this.pinnedToBottom,r=e.scrollTop<this.lastScrollTop;if(t&&n){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:r?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){let e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){let 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;let e=this.chat;e&&oy({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(){let e=this.chat;return!e||by(e)}isAtBottom(){let e=this.chat;return!e||yy(e)<2}canScrollUp(){let e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;let e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}restoreScrollPosition(){let e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{let t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){let 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(()=>{let n=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,n)})}))}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;let n=this.chat;n===void 0||!this.hasMore||this.loadingMore||(n.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore}updatePinnedToBottomAfterRestore(e){e===`bottom`?this.pinnedToBottom=!0:e===`restored`&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){let e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){let e=this.chat;if(e)return Qv(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;let t=this.prependRestoreToken+1;this.prependRestoreToken=t;let n=0,r=()=>{let i=this.chat;if(!(!i||t!==this.prependRestoreToken)){if($v(i,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=i.scrollTop,n+=1,n<30){requestAnimationFrame(r);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};r()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){let e=this.sessionId;this.scrollController.scheduleSave(e,e=>{this.sessionId===e&&this.saveScrollPosition(e)})}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}let e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),n=Number(t?.dataset.index);if(Number.isFinite(n)){this.currentConversationIndex=Qx(n,0,Math.max(0,e-1));return}this.currentConversationIndex=Qx(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(){let e=this.chat;if(e!==void 0)return Cy(e,Array.from(this.renderRoot.querySelectorAll(`article.msg`)))??Cy(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,n){return n?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return nS(e)}groupRenderKey(e){return rS(e)}groupAnchorKey(e){return rS(e)}eventAnchorKey(e){return iS(e)}messageScrollMarkerId(e){return nS(e)}groupScrollMarkerId(e){return aS(e)}_updateMinimapViewport(){let e=this.chat;e&&(this._minimapViewport=Ey({scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,scrollTop:e.scrollTop}),this._minimapLoadedPercent=this.hasMore?Zx(this.messages.length/this.conversationDisplayTotal()*100):100)}_requestMinimapMeasure(){this._minimapMeasureTimer===void 0&&(this._minimapMeasureTimer=setTimeout(()=>{this._minimapMeasureTimer=void 0,this._measureMinimapMarkers(),this._updateMinimapViewport()},150))}_measureMinimapMarkers(){let e=this.chat;if(!e||!this.messages.length){this._minimapMarkers=[];return}let t=e.getBoundingClientRect(),n=e.scrollHeight;if(n<=0){this._minimapMarkers=[];return}let r=this.renderRoot.querySelectorAll(`article.msg.user, article.msg.assistant`),i=[];for(let a of r){let r=a.dataset.index;if(r===void 0)continue;let o=Number(r);if(!Number.isFinite(o))continue;let s=o-this.messageStart;if(s<0||s>=this.messages.length)continue;let c=this.messages[s];if(c===void 0)continue;let l=this._minimapMessagePreview(c);if(!l)continue;let u=ky(a.getBoundingClientRect().top,t.top,e.scrollTop,n);if(c.role!==`user`&&c.role!==`assistant`)continue;let d=c.role;i.push({topRatio:u,role:d,preview:l})}this._minimapMarkers=i}_minimapMessagePreview(e){return e.parts.filter(e=>e.type===`text`).map(e=>e.text.trim()).filter(e=>e!==``).join(` `).slice(0,200)}_onMinimapScrollTo(e){let t=Ny(e.detail);if(t===void 0)return;let n=this.chat;if(!n)return;let r=n.scrollHeight-n.clientHeight;r<=0||(n.scrollTop=Dy(t/(1-this._minimapViewport.viewportRatio))*r,this.pinnedToBottom=by(n))}static{this.styles=Jp}};B([x({attribute:!1})],G.prototype,`messages`,void 0),B([x()],G.prototype,`sessionId`,void 0),B([x({type:Number})],G.prototype,`messageStart`,void 0),B([x({type:Number})],G.prototype,`messageEnd`,void 0),B([x({type:Number})],G.prototype,`messageTotal`,void 0),B([x({type:Boolean})],G.prototype,`hasMore`,void 0),B([x({type:Boolean})],G.prototype,`loadingMore`,void 0),B([x({type:Boolean})],G.prototype,`isSendingPrompt`,void 0),B([x({type:Boolean})],G.prototype,`isCompacting`,void 0),B([x({type:Number})],G.prototype,`pendingMessageCount`,void 0),B([x({attribute:!1})],G.prototype,`clientQueuedMessages`,void 0),B([x({attribute:!1})],G.prototype,`status`,void 0),B([x({type:Number})],G.prototype,`warningCount`,void 0),B([x({type:Boolean})],G.prototype,`warningsExpanded`,void 0),B([x({attribute:!1})],G.prototype,`onToggleWarnings`,void 0),B([x({attribute:!1})],G.prototype,`activity`,void 0),B([x({attribute:!1})],G.prototype,`sessionInfo`,void 0),B([x({attribute:!1})],G.prototype,`notificationInbox`,void 0),B([x({type:Boolean})],G.prototype,`canClearServerQueue`,void 0),B([x({type:Boolean})],G.prototype,`canMessageActions`,void 0),B([x({attribute:!1})],G.prototype,`onEditFromHere`,void 0),B([x({attribute:!1})],G.prototype,`onForkFromHere`,void 0),B([x({attribute:!1})],G.prototype,`onClearServerQueue`,void 0),B([x({attribute:!1})],G.prototype,`onDismissWarning`,void 0),B([x({attribute:!1})],G.prototype,`onDismissNotification`,void 0),B([x({attribute:!1})],G.prototype,`onDismissAllNotifications`,void 0),B([x({type:Boolean})],G.prototype,`warningsVisible`,void 0),B([x({attribute:!1})],G.prototype,`onLoadMore`,void 0),B([C(`.chat`)],G.prototype,`chat`,void 0),B([C(`dialog.image-zoom`)],G.prototype,`imageZoomDialog`,void 0),B([S()],G.prototype,`pinnedToBottom`,void 0),B([S()],G.prototype,`zoomedImage`,void 0),B([S()],G.prototype,`expandedMetaKey`,void 0),B([S()],G.prototype,`copiedMessageKey`,void 0),B([S()],G.prototype,`forkingEntryId`,void 0),B([S()],G.prototype,`currentConversationIndex`,void 0),B([S()],G.prototype,`collapsedNotificationTargetKeys`,void 0),B([S()],G.prototype,`retainedEmptyNotificationTrayTargetKey`,void 0),B([S()],G.prototype,`loadMoreRequested`,void 0),B([S()],G.prototype,`sessionInfoOpen`,void 0),B([S()],G.prototype,`_minimapMarkers`,void 0),B([S()],G.prototype,`_minimapViewport`,void 0),G=B([b(`chat-view`)],G);var vS=new Set([`image/jpeg`,`image/png`,`image/gif`,`image/webp`]);function yS(e){return typeof e==`string`&&vS.has(e)}function bS(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`}}var xS=`application/octet-stream`,SS=`Failed to read an attachment.`;async function CS(e,t){let n=[],r;for(let i of e)try{let e=await t(i);n.push(DS(i,e))}catch{r=SS}return{attachments:n,...r===void 0?{}:{error:r}}}function wS(e){return e.kind===`image`&&yS(e.mimeType)}function TS(e){return e.every(e=>wS(e))}function ES(e,t){return TS(t)?e:`folder`}function DS(e,t){return yS(e.type)?{kind:`image`,name:kS(e),mimeType:e.type,data:t,size:e.size}:{kind:`file`,name:kS(e),mimeType:OS(e),data:t,size:e.size}}function OS(e){let t=e.type.trim();return t===``?xS:t}function kS(e){return e.name===``?yS(e.type)?`pasted-image.${bS(e.type)}`:`pasted-file.bin`:e.name}var AS=`pi-webui:attachment-delivery`;function jS(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function MS(e=jS()){try{return e?.getItem(AS)===`folder`?`folder`:`inline`}catch{return`inline`}}function NS(e,t=jS()){try{t?.setItem(AS,e)}catch{}}var PS=`(pointer: coarse), (max-width: 760px)`,FS=`pi-webui.promptEnterPreference`;function IS(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(PS):void 0}function LS(e){return e===`send`||e===`newline`?e:`auto`}function RS(e=US()){if(e===void 0)return`auto`;try{return LS(e.getItem(FS))}catch{return`auto`}}function zS(e,t=US()){if(t!==void 0)try{t.setItem(FS,e)}catch{}}function BS(e=IS(),t=RS()){return t===`send`||t!==`newline`&&e?.matches!==!0}function VS(e,t,n=IS()){return e?n?.matches!==!0||t:!1}function HS(e,t=IS(),n=RS()){let r=BS(t,n);return e?!r:r}function US(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}function WS(){return _`
|
|
2747
2871
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2748
2872
|
<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>
|
|
2749
2873
|
</svg>
|
|
2750
|
-
`}function
|
|
2874
|
+
`}function GS(){return _`
|
|
2751
2875
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2752
2876
|
<polyline points="4 14 10 14 10 20"></polyline>
|
|
2753
2877
|
<polyline points="20 10 14 10 14 4"></polyline>
|
|
2754
2878
|
<line x1="10" y1="14" x2="3" y2="21"></line>
|
|
2755
2879
|
<line x1="21" y1="3" x2="14" y2="10"></line>
|
|
2756
2880
|
</svg>
|
|
2757
|
-
`}function
|
|
2881
|
+
`}function KS(){return _`
|
|
2758
2882
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2759
2883
|
<path d="M21 3 13.5 21l-2-8.5L3 10.5Z"></path>
|
|
2760
2884
|
<path d="M21 3 11.5 12.5"></path>
|
|
2761
2885
|
</svg>
|
|
2762
|
-
`}function
|
|
2886
|
+
`}function qS(){return _`
|
|
2763
2887
|
<svg class="prompt-action-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2764
2888
|
<path d="M4 7h11"></path>
|
|
2765
2889
|
<path d="M4 12h7"></path>
|
|
2766
2890
|
<path d="M4 17h7"></path>
|
|
2767
2891
|
<path d="m15 14 5 3-5 3z"></path>
|
|
2768
2892
|
</svg>
|
|
2769
|
-
`}function
|
|
2893
|
+
`}function JS(){return KS()}function YS(){return _`
|
|
2770
2894
|
<svg class="prompt-action-icon prompt-action-icon-filled" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2771
2895
|
<rect x="6.5" y="6.5" width="11" height="11" rx="2"></rect>
|
|
2772
2896
|
</svg>
|
|
2773
|
-
`}function
|
|
2897
|
+
`}function XS(e){let t=Math.max(e.total,1),n=t>1?1.2:0,r=(18-n*(t-1))/t;return _`
|
|
2774
2898
|
<svg class="prompt-thinking-gauge" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
2775
2899
|
${Array.from({length:t},(i,a)=>{let o=3+a*(r+n),s=4+(a+1)/t*12,c=20-s;return _`<rect class=${a<e.filled?`gauge-bar gauge-bar-active`:`gauge-bar`} x=${o} y=${c} width=${r} height=${s} rx="1"></rect>`})}
|
|
2776
2900
|
</svg>
|
|
2777
|
-
`}var
|
|
2901
|
+
`}var ZS=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function QS(e){return e===void 0||e===``?`off`:e}function $S(e,t){let n=t.length>=2?t:ZS,r=n.length-1,i=QS(e),a=n.indexOf(i);return{total:r,filled:a<=0?0:Math.min(a,r)}}var eC=S_(class extends C_{constructor(e){super(e),this.wasSelected=!1,this.isElementPart=e.type===x_.ELEMENT}update(e,[t,n]){if(!this.isElementPart)throw Error(`scrollWhenSelected must be used on an element`);if(t&&(!this.wasSelected||n!==this.previousKey)){let t=`element`in e?e.element:void 0;requestAnimationFrame(()=>{t instanceof HTMLElement&&t.scrollIntoView({block:`nearest`})})}this.wasSelected=t,this.previousKey=n}render(e,t){}}),tC=class extends y{constructor(...e){super(...e),this.items=[],this.selectedIndex=0}render(){return this.items.length?g`
|
|
2778
2902
|
<div class="menu">
|
|
2779
2903
|
${this.items.map((e,t)=>g`
|
|
2780
|
-
<button class=${t===this.selectedIndex?`selected`:``} ${
|
|
2904
|
+
<button class=${t===this.selectedIndex?`selected`:``} ${eC(t===this.selectedIndex,e)} @mousedown=${t=>{t.preventDefault(),this.onPick?.(e)}}>
|
|
2781
2905
|
<strong>${e.insertText}</strong>
|
|
2782
2906
|
<span>${e.detail}</span>
|
|
2783
2907
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
2784
2908
|
</button>
|
|
2785
2909
|
`)}
|
|
2786
2910
|
</div>
|
|
2787
|
-
`:null}static{this.styles=Xp}};B([x({attribute:!1})],
|
|
2911
|
+
`:null}static{this.styles=Xp}};B([x({attribute:!1})],tC.prototype,`items`,void 0),B([x({type:Number})],tC.prototype,`selectedIndex`,void 0),B([x({attribute:!1})],tC.prototype,`onPick`,void 0),tC=B([b(`autocomplete-menu`)],tC);var K=class extends y{constructor(...e){super(...e),this.disabled=!1,this.machineId=`local`,this.workspaceScopedFileSuggestions=!1,this.canSteer=!1,this.isCompacting=!1,this.canStop=!1,this.sending=!1,this.showSessionConfiguration=!1,this.availableThinkingLevels=[],this.draft=``,this.currentInputMode={kind:`normal`},this.completions=[],this.selectedIndex=0,this.attachments=[],this.attachmentDelivery=MS(),this.attachmentError=void 0,this.attachmentSeq=0,this.requestVersion=0,this.editableCompartment=new s,this.readOnlyCompartment=new s,this.mobilePromptEnterMedia=IS(),this.explicitShiftKeyActive=!1}willUpdate(e){if(!e.has(`sessionId`)&&!e.has(`machineId`))return;let t=e.has(`sessionId`)?e.get(`sessionId`):this.sessionId,n=rC(e.has(`machineId`)?e.get(`machineId`):this.machineId,t);n!==void 0&&Vc(n,this.draft);let r=rC(this.machineId,this.sessionId);this.draft=r===void 0?``:Bc(r),this.currentInputMode=Yl(this.draft),this.completions=[],this.selectedIndex=0}shouldUpdate(e){return e.has(`status`)&&e.size===1?!nC(e.get(`status`),this.status):!0}firstUpdated(){this.createEditor()}updated(e){e.has(`disabled`)&&this.updateEditorDisabledState(),(e.has(`sessionId`)||e.has(`machineId`))&&this.syncEditorDoc()}disconnectedCallback(){this.editor?.destroy(),this.editor=void 0,super.disconnectedCallback()}render(){let e=this.currentInputMode.kind===`shell`?this.currentInputMode:void 0,t=e!==void 0,n=this.canSteer||this.isCompacting,r=this.disabled||this.sending,i=r||this.canSteer||this.isCompacting||this.canStop;return g`
|
|
2788
2912
|
<footer class=${t?`shell-mode`:``} @paste=${e=>{this.handlePaste(e)}} @dragover=${e=>{this.handleDragOver(e)}} @drop=${e=>{this.handleDrop(e)}}>
|
|
2789
2913
|
<div class="editor-wrap">
|
|
2790
2914
|
<div class=${`markdown-editor${this.disabled?` markdown-editor-disabled`:``}`} aria-label="Message pi" aria-disabled=${this.disabled?`true`:`false`}></div>
|
|
2791
2915
|
<input class="attachment-input" type="file" multiple hidden @change=${e=>{this.handleFileInput(e)}} />
|
|
2792
|
-
<button class="editor-attach icon-button" ?disabled=${r} title="Attach files" aria-label="Attach files" @click=${()=>{this.attachmentInput?.click()}}>${
|
|
2916
|
+
<button class="editor-attach icon-button" ?disabled=${r} title="Attach files" aria-label="Attach files" @click=${()=>{this.attachmentInput?.click()}}>${WS()}</button>
|
|
2793
2917
|
${t?g`<div class="mode-hint">Shell command${e.excludeFromContext?` · excluded from context`:``}</div>`:null}
|
|
2794
2918
|
${this.isCompacting&&!t?g`<div class="mode-hint">Compacting history · message will be queued</div>`:null}
|
|
2795
2919
|
${this.renderAttachments()}
|
|
@@ -2797,21 +2921,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2797
2921
|
</div>
|
|
2798
2922
|
<div class="actions">
|
|
2799
2923
|
${this.renderCompactStatus()}
|
|
2800
|
-
${this.onCompact===void 0?null:g`<button class="compact-button" ?disabled=${i} title="Compact context" aria-label="Compact context" @click=${()=>this.onCompact?.()}>${
|
|
2801
|
-
<button class="icon-button send-button" ?disabled=${r} title=${n?`Queue until the current activity finishes`:`Send message`} aria-label=${n?`Queue message`:`Send message`} @click=${()=>{this.send(`followUp`)}}>${n?
|
|
2802
|
-
${this.canSteer&&!this.isCompacting?g`<button class="icon-button steer-button" ?disabled=${r} title="Steer the current response before the next model call" aria-label="Steer current response" @click=${()=>{this.send(`steer`)}}>${
|
|
2803
|
-
<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?.()}>${
|
|
2924
|
+
${this.onCompact===void 0?null:g`<button class="compact-button" ?disabled=${i} title="Compact context" aria-label="Compact context" @click=${()=>this.onCompact?.()}>${GS()}<span>Compact</span></button>`}
|
|
2925
|
+
<button class="icon-button send-button" ?disabled=${r} title=${n?`Queue until the current activity finishes`:`Send message`} aria-label=${n?`Queue message`:`Send message`} @click=${()=>{this.send(`followUp`)}}>${n?qS():KS()}</button>
|
|
2926
|
+
${this.canSteer&&!this.isCompacting?g`<button class="icon-button steer-button" ?disabled=${r} title="Steer the current response before the next model call" aria-label="Steer current response" @click=${()=>{this.send(`steer`)}}>${JS()}</button>`:null}
|
|
2927
|
+
<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?.()}>${YS()}</button>
|
|
2804
2928
|
</div>
|
|
2805
2929
|
</footer>
|
|
2806
|
-
`}focusInput(){this.editor?.focus()}replaceText(e){this.draft=e;let t=
|
|
2930
|
+
`}focusInput(){this.editor?.focus()}replaceText(e){this.draft=e;let t=rC(this.machineId,this.sessionId);t!==void 0&&Vc(t,e);let n=this.editor;if(n!==void 0){let t=n.state.doc.toString();n.dispatch({...t===e?{}:{changes:{from:0,to:t.length,insert:e}},selection:i.cursor(e.length)})}this.requestVersion+=1,this.currentInputMode=Yl(e),this.completions=[],this.selectedIndex=0}get view(){return this.editor}renderCompactStatus(){let e=this.status===void 0&&this.showSessionConfiguration,t=this.status??(e?this.sessionConfiguration:void 0);if(t===void 0&&!e)return null;let n=t?.model?.id??(e?`Choose default model`:`no model`),r=t?.model?.provider!==void 0&&t.model.provider!==``?`${t.model.provider}/`:``,i=e?`Default thinking level: ${QS(t?.thinkingLevel)}`:`Thinking level: ${QS(t?.thinkingLevel)}`;return g`
|
|
2807
2931
|
<div class="compact-status" aria-label=${e?`Session defaults`:`Session status`}>
|
|
2808
2932
|
<button class="select-model" ?disabled=${this.onSelectModel===void 0} title="Select model" @click=${()=>this.onSelectModel?.()}>${r}${n}</button>
|
|
2809
|
-
<button class="select-thinking icon-button" ?disabled=${this.onSelectThinking===void 0} title=${i} aria-label=${i} @click=${()=>this.onSelectThinking?.()}>${
|
|
2933
|
+
<button class="select-thinking icon-button" ?disabled=${this.onSelectThinking===void 0} title=${i} aria-label=${i} @click=${()=>this.onSelectThinking?.()}>${XS($S(t?.thinkingLevel,this.availableThinkingLevels))}</button>
|
|
2810
2934
|
</div>
|
|
2811
|
-
`}renderAttachments(){if(this.attachments.length===0&&this.attachmentError===void 0)return null;let e=
|
|
2935
|
+
`}renderAttachments(){if(this.attachments.length===0&&this.attachmentError===void 0)return null;let e=TS(this.attachments),t=this.effectiveAttachmentDelivery();return g`
|
|
2812
2936
|
<div class="attachments" aria-label="Pending attachments">
|
|
2813
2937
|
${this.attachments.map(e=>g`
|
|
2814
|
-
<div class=${`attachment-chip ${
|
|
2938
|
+
<div class=${`attachment-chip ${wS(e)?`attachment-chip-image`:`attachment-chip-file`}`} title=${e.name}>
|
|
2815
2939
|
${this.renderAttachmentPreview(e)}
|
|
2816
2940
|
<button type="button" class="attachment-remove" title="Remove attachment" aria-label=${`Remove ${e.name}`} @click=${()=>{this.removeAttachment(e.id)}}>×</button>
|
|
2817
2941
|
</div>
|
|
@@ -2826,10 +2950,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2826
2950
|
`:null}
|
|
2827
2951
|
${this.attachmentError===void 0?null:g`<div class="attachment-error">${this.attachmentError}</div>`}
|
|
2828
2952
|
</div>
|
|
2829
|
-
`}renderAttachmentPreview(e){return
|
|
2830
|
-
<div class="attachment-file-preview" aria-hidden="true">${
|
|
2953
|
+
`}renderAttachmentPreview(e){return wS(e)?g`<img src=${`data:${e.mimeType};base64,${e.data}`} alt=${e.name} />`:g`
|
|
2954
|
+
<div class="attachment-file-preview" aria-hidden="true">${lC(e.name)}</div>
|
|
2831
2955
|
<span class="attachment-file-name">${e.name}</span>
|
|
2832
|
-
`}changeDelivery(e){if(!(e.target instanceof HTMLSelectElement))return;let t=e.target.value===`folder`?`folder`:`inline`;if(t===`inline`&&!
|
|
2956
|
+
`}changeDelivery(e){if(!(e.target instanceof HTMLSelectElement))return;let t=e.target.value===`folder`?`folder`:`inline`;if(t===`inline`&&!TS(this.attachments)){e.target.value=`folder`;return}this.attachmentDelivery=t,NS(this.attachmentDelivery)}removeAttachment(e){this.attachments=this.attachments.filter(t=>t.id!==e)}async handlePaste(e){let t=oC(e.clipboardData);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}handleDragOver(e){e.dataTransfer!==null&&sC(e.dataTransfer)&&e.preventDefault()}async handleDrop(e){let t=oC(e.dataTransfer);t.length!==0&&(e.preventDefault(),await this.addAttachmentFiles(t))}async handleFileInput(e){if(!(e.target instanceof HTMLInputElement)||e.target.files===null)return;let t=Array.from(e.target.files);e.target.value=``,await this.addAttachmentFiles(t)}async addAttachmentFiles(e){this.attachmentError=void 0;let{attachments:t,error:n}=await CS(e,uC);t.length>0&&(this.attachments=[...this.attachments,...t.map(e=>({id:`attachment-${String(++this.attachmentSeq)}`,...e}))]),n!==void 0&&(this.attachmentError=n)}currentAttachments(){return this.attachments.map(e=>cC(e))}effectiveAttachmentDelivery(){return ES(this.attachmentDelivery,this.attachments)}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new p({parent:this.editorHost,state:e.create({doc:this.draft,extensions:[m(),ne(),t(),u.of(` `),r(a,{fallback:!0}),p.lineWrapping,p.contentAttributes.of(e=>pC(e.state.sliceDoc(0,e.state.selection.main.head))),p.domEventHandlers({keyup:e=>this.handleEditorKeyUp(e),blur:()=>this.resetEditorModifierState()}),o(`Message pi... Use / for commands, @ for tracked files, @ space for all files`),this.editableCompartment.of(p.editable.of(!this.disabled)),this.readOnlyCompartment.of(e.readOnly.of(this.disabled)),p.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),n.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=>l.shift?.(e)??!1},{key:`Backspace`,run:e=>ee(e)},...c,...d])]})}))}syncEditorDoc(){let e=this.editor;if(!e)return;let t=e.state.doc.toString();t!==this.draft&&e.dispatch({changes:{from:0,to:t.length,insert:this.draft},selection:i.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(p.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(e.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e;let t=rC(this.machineId,this.sessionId);t!==void 0&&Vc(t,this.draft);let n=Yl(this.draft);Zl(n,this.currentInputMode)||(this.currentInputMode=n),this.refreshCompletions()}async refreshCompletions(){let 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!==``){let n=await L.commands({id:this.sessionId,cwd:this.cwd},this.machineId).catch(iC);if(t!==this.requestVersion)return;this.completions=n.filter(t=>t.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(t=>({kind:`command`,replaceFrom:e.from,replaceTo:e.to,insertText:`/${t.name}`,detail:t.source,...t.description===void 0?{}:{description:t.description}}))}else if(e.kind===`file`&&this.cwd!==void 0&&this.cwd!==``){let n=await L.files(this.cwd,e.query,{scope:e.fileScope,machineId:this.machineId,projectId:this.projectId,workspaceId:this.workspaceId,workspaceScoped:this.workspaceScopedFileSuggestions}).catch(aC);if(t!==this.requestVersion)return;this.completions=n.slice(0,12).map(t=>{let n=Wl(t.path,e.quoted===!0,t.path.endsWith(`/`)?e.allPrefix:void 0);return{kind:`file`,replaceFrom:e.from,replaceTo:e.to,insertText:n,detail:t.kind,...t.path.endsWith(`/`)&&n.endsWith(`"`)?{cursorOffset:n.length-1}:{}}})}}currentTrigger(){return Ul(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;let n=VS(e.shiftKey,this.explicitShiftKeyActive,this.mobilePromptEnterMedia);return this.explicitShiftKeyActive=!1,this.handleEditorEnter(t,n)}handleEditorKeyUp(e){return e.key===`Shift`&&(this.explicitShiftKeyActive=!1),!1}resetEditorModifierState(){return this.explicitShiftKeyActive=!1,!1}handleEditorEnter(e,t){if(!t&&this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return HS(t,this.mobilePromptEnterMedia,RS())?(this.send(this.canSteer||this.isCompacting?`followUp`:void 0),!0):te(e)||f(e)}handleEditorTab(e){if(this.completions.length){let e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return this.currentTrigger()?.kind===`file`?(this.refreshCompletions(),!0):l.run?.(e)??!1}pick(e){let t=this.editor;if(!t)return;let n=e.kind===`file`&&(e.insertText.endsWith(`/`)||e.cursorOffset!==void 0)?``:` `,r=e.replaceFrom+(e.cursorOffset??e.insertText.length)+n.length,a=e.insertText.endsWith(`"`)&&this.draft.slice(e.replaceTo).startsWith(`"`)?e.replaceTo+1:e.replaceTo;t.dispatch({changes:{from:e.replaceFrom,to:a,insert:`${e.insertText}${n}`},selection:i.cursor(r),scrollIntoView:!0}),this.completions=[]}send(e){if(this.disabled||this.sending)return;let t=this.draft.trim(),n=this.attachments;if(t===``&&n.length===0)return;let r=this.canSteer||this.isCompacting?e:void 0,i=n.length>0?this.currentAttachments():void 0,a=this.effectiveAttachmentDelivery();this.resetComposer(),this.onSend?.(t,r,i,i===void 0?void 0:a)}resetComposer(){this.draft=``,this.currentInputMode={kind:`normal`};let e=rC(this.machineId,this.sessionId);e!==void 0&&Hc(e),this.completions=[],this.attachments=[],this.attachmentError=void 0,this.syncEditorDoc()}static{this.styles=$p}};B([x({type:Boolean})],K.prototype,`disabled`,void 0),B([x()],K.prototype,`sessionId`,void 0),B([x()],K.prototype,`cwd`,void 0),B([x()],K.prototype,`machineId`,void 0),B([x()],K.prototype,`projectId`,void 0),B([x()],K.prototype,`workspaceId`,void 0),B([x({type:Boolean})],K.prototype,`workspaceScopedFileSuggestions`,void 0),B([x({type:Boolean})],K.prototype,`canSteer`,void 0),B([x({type:Boolean})],K.prototype,`isCompacting`,void 0),B([x({type:Boolean})],K.prototype,`canStop`,void 0),B([x({attribute:!1})],K.prototype,`status`,void 0),B([x({type:Boolean})],K.prototype,`sending`,void 0),B([x({attribute:!1})],K.prototype,`onSend`,void 0),B([x({attribute:!1})],K.prototype,`onStop`,void 0),B([x({attribute:!1})],K.prototype,`onSelectModel`,void 0),B([x({attribute:!1})],K.prototype,`onSelectThinking`,void 0),B([x({attribute:!1})],K.prototype,`onCompact`,void 0),B([x({type:Boolean})],K.prototype,`showSessionConfiguration`,void 0),B([x({attribute:!1})],K.prototype,`sessionConfiguration`,void 0),B([x({attribute:!1})],K.prototype,`availableThinkingLevels`,void 0),B([C(`.markdown-editor`)],K.prototype,`editorHost`,void 0),B([C(`.attachment-input`)],K.prototype,`attachmentInput`,void 0),B([S()],K.prototype,`currentInputMode`,void 0),B([S()],K.prototype,`completions`,void 0),B([S()],K.prototype,`selectedIndex`,void 0),B([S()],K.prototype,`attachments`,void 0),B([S()],K.prototype,`attachmentDelivery`,void 0),B([S()],K.prototype,`attachmentError`,void 0),K=B([b(`prompt-editor`)],K);function nC(e,t){return e===t?!0:e===void 0||t===void 0?!1:e.model?.id===t.model?.id&&e.model?.provider===t.model?.provider&&e.thinkingLevel===t.thinkingLevel}function rC(e,t){if(!(typeof e!=`string`||e===``)&&!(typeof t!=`string`||t===``))return Wo(e,t)}function iC(){return[]}function aC(){return[]}function oC(e){return e===null?[]:Array.from(e.files)}function sC(e){let t=Array.from(e.items);return t.length>0?t.some(e=>e.kind===`file`):Array.from(e.types).includes(`Files`)}function cC(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 lC(e){let t=e.trim(),n=t.lastIndexOf(`.`);return n>=0&&n<t.length-1?t.slice(n+1,n+5).toUpperCase():`FILE`}function uC(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>{n(r.error??Error(`Failed to read file`))},r.onload=()=>{let e=r.result;if(typeof e!=`string`){n(Error(`Unexpected file reader result`));return}let i=e.indexOf(`,`);t(i===-1?e:e.slice(i+1))},r.readAsDataURL(e)})}var dC={spellcheck:`true`,autocorrect:`on`,autocapitalize:`sentences`,writingsuggestions:`true`,dir:`auto`},fC={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,dir:`auto`};function pC(e){return Yl(e).kind===`normal`?dC:fC}var mC=class extends y{constructor(...e){super(...e),this.title=`Select`,this.searchable=!1,this.options=[],this.selectedIndex=0,this.query=``}render(){let e=this.filteredOptions();return g`
|
|
2833
2957
|
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
2834
2958
|
<section @mousedown=${e=>{e.stopPropagation()}}>
|
|
2835
2959
|
<header>
|
|
@@ -2845,12 +2969,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2845
2969
|
`}firstUpdated(){this.selectInitialValue(),this.renderRoot.querySelector(this.searchable?`input`:`.options`)?.focus()}selectInitialValue(){if(this.selectedValue===void 0)return;let e=this.filteredOptions().findIndex(e=>e.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){let e=this.query.trim().toLowerCase();return e===``?this.options:this.options.filter(t=>`${t.label} ${t.description??``} ${t.value}`.toLowerCase().includes(e))}renderGroupedOptions(e){let t=[];for(let[n,r]of e.entries()){let e=t[t.length-1];e!==void 0&&e.group===r.group?e.items.push({option:r,index:n}):t.push({group:r.group,items:[{option:r,index:n}]})}return t.map(e=>{let t=e.group!==void 0&&e.group!==``;return g`
|
|
2846
2970
|
${t?g`<div class="group-header">${e.group}</div>`:null}
|
|
2847
2971
|
${e.items.map(({option:e,index:n})=>g`
|
|
2848
|
-
<button class="${n===this.selectedIndex?`selected`:``}${t?` grouped`:``}" ${
|
|
2972
|
+
<button class="${n===this.selectedIndex?`selected`:``}${t?` grouped`:``}" ${eC(n===this.selectedIndex,e.value)} @click=${()=>this.onPick?.(e.value)}>
|
|
2849
2973
|
<span>${e.label}</span>
|
|
2850
2974
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
2851
2975
|
</button>
|
|
2852
2976
|
`)}
|
|
2853
|
-
`})}handleKeyDown(e){let 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();let n=t[this.selectedIndex];n&&this.onPick?.(n.value)}}static{this.styles=Zp}};B([x()],
|
|
2977
|
+
`})}handleKeyDown(e){let 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();let n=t[this.selectedIndex];n&&this.onPick?.(n.value)}}static{this.styles=Zp}};B([x()],mC.prototype,`title`,void 0),B([x({type:Boolean})],mC.prototype,`searchable`,void 0),B([x({attribute:!1})],mC.prototype,`options`,void 0),B([x({attribute:!1})],mC.prototype,`selectedValue`,void 0),B([x({attribute:!1})],mC.prototype,`onPick`,void 0),B([x({attribute:!1})],mC.prototype,`onCancel`,void 0),B([S()],mC.prototype,`selectedIndex`,void 0),B([S()],mC.prototype,`query`,void 0),mC=B([b(`command-picker`)],mC);var hC=class extends y{constructor(...e){super(...e),this.actions=[],this.queryText=``,this.selectedIndex=0}render(){let e=this.filteredActions();return g`
|
|
2854
2978
|
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
2855
2979
|
<section @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
2856
2980
|
<header>
|
|
@@ -2863,7 +2987,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2863
2987
|
</header>
|
|
2864
2988
|
<div class="options">
|
|
2865
2989
|
${e.length===0?g`<div class="empty">No actions found.</div>`:e.map((e,t)=>g`
|
|
2866
|
-
<button class=${`${t===this.selectedIndex?`selected`:``} ${e.enabled===!1?`disabled`:``}`} ?disabled=${e.enabled===!1} title=${e.disabledReason??e.title} ${
|
|
2990
|
+
<button class=${`${t===this.selectedIndex?`selected`:``} ${e.enabled===!1?`disabled`:``}`} ?disabled=${e.enabled===!1} title=${e.disabledReason??e.title} ${eC(t===this.selectedIndex,e.id)} @click=${()=>{this.run(e)}}>
|
|
2867
2991
|
<span class="main">
|
|
2868
2992
|
<strong>${e.title}</strong>
|
|
2869
2993
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
@@ -2876,7 +3000,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2876
3000
|
</div>
|
|
2877
3001
|
</section>
|
|
2878
3002
|
</div>
|
|
2879
|
-
`}firstUpdated(){this.input?.focus()}updated(e){if(!e.has(`actions`)&&!e.has(`queryText`))return;let t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){return
|
|
3003
|
+
`}firstUpdated(){this.input?.focus()}updated(e){if(!e.has(`actions`)&&!e.has(`queryText`))return;let t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){return gC(this.actions,this.queryText)}handleKeyDown(e){let 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();let n=t[this.selectedIndex];n!==void 0&&this.run(n)}}run(e){e.enabled!==!1&&this.onRun?.(e)}static{this.styles=Qp}};B([x({attribute:!1})],hC.prototype,`actions`,void 0),B([x({attribute:!1})],hC.prototype,`onRun`,void 0),B([x({attribute:!1})],hC.prototype,`onCancel`,void 0),B([C(`input`)],hC.prototype,`input`,void 0),B([S()],hC.prototype,`queryText`,void 0),B([S()],hC.prototype,`selectedIndex`,void 0),hC=B([b(`action-palette`)],hC);function gC(e,t){let n=t.trim().toLowerCase();return e.filter(e=>e.enabled!==!1||e.disabledReason!==void 0).filter(e=>n===``||[e.title,e.description??``,e.disabledReason??``,e.group??``,e.shortcut??``].join(` `).toLowerCase().includes(n))}var _C=class extends y{render(){let e=this.state;return e===void 0?null:g`
|
|
2880
3004
|
<div class="backdrop" @mousedown=${()=>{this.cancel()}}>
|
|
2881
3005
|
<section @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
2882
3006
|
<header>
|
|
@@ -2899,13 +3023,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2899
3023
|
<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>
|
|
2900
3024
|
</div>
|
|
2901
3025
|
`;case`oauth`:return this.renderOAuth(e);case`logout`:return g`<div class="options">${e.providers.length===0?g`<div class="empty">No stored credentials. Environment variables and models.json settings are unchanged.</div>`:e.providers.map(e=>g`
|
|
2902
|
-
<button @click=${()=>{this.onLogoutProvider?.(e.id)}}><span>${e.name}</span><small>${e.id} · ${
|
|
3026
|
+
<button @click=${()=>{this.onLogoutProvider?.(e.id)}}><span>${e.name}</span><small>${e.id} · ${yC(e.authType)}</small></button>
|
|
2903
3027
|
`)}</div>`}}renderProviderButton(e){return g`
|
|
2904
3028
|
<button @click=${()=>{this.onSelectProvider?.(e.id,e.authType)}}>
|
|
2905
|
-
<span>${e.name}${e.status.source===void 0?null:g` <em>${
|
|
2906
|
-
<small>${e.id} · ${
|
|
3029
|
+
<span>${e.name}${e.status.source===void 0?null:g` <em>${xC(e)}</em>`}</span>
|
|
3030
|
+
<small>${e.id} · ${yC(e.authType)}</small>
|
|
2907
3031
|
</button>
|
|
2908
|
-
`}renderOAuth(e){let t=e.flow,n=t.prompt,r=t.select,i=
|
|
3032
|
+
`}renderOAuth(e){let t=e.flow,n=t.prompt,r=t.select,i=vC(n?.promptType);return g`
|
|
2909
3033
|
<div class="form">
|
|
2910
3034
|
${t.auth===void 0?g`<p>Starting login flow…</p>`:g`
|
|
2911
3035
|
<p>Open this authorization link:</p>
|
|
@@ -2938,7 +3062,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2938
3062
|
${t.status===`error`||t.status===`cancelled`?g`<div class="error-text">${t.error??t.status}</div><div class="actions"><button @click=${()=>{this.cancel()}}>Close</button></div>`:null}
|
|
2939
3063
|
${n===void 0&&r===void 0&&t.status===`running`?g`<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button></div>`:null}
|
|
2940
3064
|
</div>
|
|
2941
|
-
`}focusInputIfNeeded(){let e=
|
|
3065
|
+
`}focusInputIfNeeded(){let e=bC(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;let 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?.()}static{this.styles=[Zp,h`
|
|
2942
3066
|
.form { display: grid; gap: 12px; padding: 14px; overflow: auto; }
|
|
2943
3067
|
.form p { margin: 0; color: var(--pi-text-secondary); overflow-wrap: anywhere; }
|
|
2944
3068
|
.form a { color: var(--pi-accent); overflow-wrap: anywhere; }
|
|
@@ -2956,7 +3080,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2956
3080
|
.inline-options button { display: grid; gap: 2px; text-align: left; }
|
|
2957
3081
|
.inline-options small { color: var(--pi-muted); }
|
|
2958
3082
|
em { color: var(--pi-success); font-style: normal; font-size: 12px; }
|
|
2959
|
-
`]}};B([x({attribute:!1})],
|
|
3083
|
+
`]}};B([x({attribute:!1})],_C.prototype,`state`,void 0),B([x({attribute:!1})],_C.prototype,`onChooseMethod`,void 0),B([x({attribute:!1})],_C.prototype,`onSelectProvider`,void 0),B([x({attribute:!1})],_C.prototype,`onApiKeyInput`,void 0),B([x({attribute:!1})],_C.prototype,`onSaveApiKey`,void 0),B([x({attribute:!1})],_C.prototype,`onLogoutProvider`,void 0),B([x({attribute:!1})],_C.prototype,`onOAuthInput`,void 0),B([x({attribute:!1})],_C.prototype,`onOAuthRespond`,void 0),B([x({attribute:!1})],_C.prototype,`onOAuthCancel`,void 0),B([x({attribute:!1})],_C.prototype,`onCancel`,void 0),B([C(`input`)],_C.prototype,`input`,void 0),_C=B([b(`auth-dialog`)],_C);function vC(e){return e===`secret`?`password`:`text`}function yC(e){return e===`oauth`?`subscription`:`credentials`}function bC(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 xC(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 SC=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],CC=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function wC(e){let t=e.providers??{},n=FC(t);return{config:MC(e,{...t,[n]:{api:`openai-completions`}}),providerName:n}}function TC(e,t,n){let r=n.trim(),i=e.providers??{};if(r===``)return{config:e,error:`Provider name is required.`};if(t===r)return{config:e};if(i[t]===void 0)return{config:e,error:`Provider "${t}" no longer exists.`};if(i[r]!==void 0)return{config:e,error:`A provider named "${r}" already exists.`};let a={};for(let[e,n]of Object.entries(i))a[e===t?r:e]=n;return{config:MC(e,a)}}function EC(e,t,n){let r=e.providers??{};return r[t]===void 0?e:MC(e,{...r,[t]:n})}function DC(e,t){let n=e.providers??{};return n[t]===void 0?e:MC(e,NC(n,t))}function OC(e,t){let n=e.providers?.[t];if(n===void 0)return e;let r=[...n.models??[],{id:``}];return EC(e,t,{...n,models:r})}function kC(e,t,n,r){let i=e.providers?.[t],a=i?.models;if(i===void 0||a===void 0||n<0||n>=a.length)return e;let o=[...a];return o[n]=r,EC(e,t,{...i,models:o})}function AC(e,t,n){let r=e.providers?.[t],i=r?.models;if(r===void 0||i===void 0||n<0||n>=i.length)return e;let a=i.filter((e,t)=>t!==n);if(a.length===0){let n={...r};return delete n.models,EC(e,t,n)}return EC(e,t,{...r,models:a})}function jC(e,t,n,r){let i=n==="default"?PC(e??{},t):{...e??{}};if(n===`disabled`&&(i[t]=null),n===`custom`){let e=r?.trim();i[t]=e===void 0||e===``?t:e}return Object.keys(i).length===0?void 0:i}function MC(e,t){return{...e,providers:t}}function NC(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function PC(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function FC(e){let t=`new-provider`,n=1;for(;e[t]!==void 0;)t=`new-provider-${String(n++)}`;return t}var IC={thinkingFormat:`deepseek`,requiresReasoningContentOnAssistantMessages:!0},LC=class extends y{constructor(...e){super(...e),this.modelsApi=Ka,this.config={providers:{}},this.loading=!0,this.saving=!1,this.error=``,this.savedMessage=``,this.providerNameDraft=``,this.renameError=``,this.advancedErrors={},this.modelTests={},this.discoveredModels={},this.loadRequestSequence=0,this.modelDiscoverySequence=0,this.modelDiscoveryRequestSequences=new Map}connectedCallback(){super.connectedCallback(),this.loadConfig()}disconnectedCallback(){this.savedMessageTimer!==void 0&&clearTimeout(this.savedMessageTimer),this.savedMessageTimer=void 0,super.disconnectedCallback()}updated(e){e.has(`machine`)&&BC(e.get(`machine`))!==this.machineId()&&(this.resetForMachineChange(),this.isConnected&&this.loadConfig())}render(){return g`
|
|
2960
3084
|
<div class="backdrop" @mousedown=${e=>{e.target===e.currentTarget&&this.close()}}>
|
|
2961
3085
|
<section class="dialog" role="dialog" aria-modal="true" aria-labelledby="models-dialog-title" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
2962
3086
|
<header>
|
|
@@ -2967,10 +3091,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2967
3091
|
</div>
|
|
2968
3092
|
<div class="header-actions">
|
|
2969
3093
|
<button class="icon-button" type="button" title="Reload models configuration" aria-label="Reload models configuration" ?disabled=${this.loading} @click=${()=>{this.loadConfig()}}>
|
|
2970
|
-
${
|
|
3094
|
+
${mw()}
|
|
2971
3095
|
</button>
|
|
2972
3096
|
<button class="icon-button" type="button" title="Close models configuration" aria-label="Close models configuration" @click=${()=>{this.close()}}>
|
|
2973
|
-
${
|
|
3097
|
+
${hw()}
|
|
2974
3098
|
</button>
|
|
2975
3099
|
</div>
|
|
2976
3100
|
</header>
|
|
@@ -2988,7 +3112,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
2988
3112
|
${this.savedMessage===``?null:g`<span class="saved-message">${this.savedMessage}</span>`}
|
|
2989
3113
|
</div>
|
|
2990
3114
|
<button type="button" class="secondary" @click=${()=>{this.configureAuth()}}>
|
|
2991
|
-
${
|
|
3115
|
+
${gw()} Authentication
|
|
2992
3116
|
</button>
|
|
2993
3117
|
<button type="button" class="secondary" @click=${()=>{this.close()}}>Close</button>
|
|
2994
3118
|
<button type="button" class="primary" ?disabled=${this.saving||this.loading} @click=${()=>{this.saveConfig()}}>
|
|
@@ -3009,28 +3133,28 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3009
3133
|
</div>
|
|
3010
3134
|
<div class="tree-actions">
|
|
3011
3135
|
<button type="button" class="add-provider" @click=${()=>{this.addCustomProvider()}}>
|
|
3012
|
-
${
|
|
3136
|
+
${fw()} Add provider
|
|
3013
3137
|
</button>
|
|
3014
3138
|
<button type="button" class="auth-link" @click=${()=>{this.configureAuth()}}>
|
|
3015
|
-
${
|
|
3139
|
+
${gw()} Configure authentication
|
|
3016
3140
|
</button>
|
|
3017
3141
|
</div>
|
|
3018
3142
|
</aside>
|
|
3019
3143
|
`}renderProviderTreeNode(e,t){let n=this.selection?.type===`provider`&&this.selection.providerName===e,r=t.models??[];return g`
|
|
3020
3144
|
<div class="provider-node">
|
|
3021
3145
|
<button class="tree-row provider-row ${n?`selected`:``}" type="button" @click=${()=>{this.selectProvider(e)}}>
|
|
3022
|
-
${
|
|
3146
|
+
${uw()}
|
|
3023
3147
|
<span class="tree-label">${e}</span>
|
|
3024
3148
|
</button>
|
|
3025
3149
|
${r.map((t,n)=>g`
|
|
3026
3150
|
<button class="tree-row model-row ${this.selection?.type===`model`&&this.selection.providerName===e&&this.selection.index===n?`selected`:``}" type="button" @click=${()=>{this.selectModel(e,n)}}>
|
|
3027
|
-
${
|
|
3151
|
+
${dw()}
|
|
3028
3152
|
<span class="tree-label">${t.id.trim()===``?`new model`:t.id}</span>
|
|
3029
3153
|
${t.reasoning===!0?g`<span class="thinking-mark" title="Reasoning enabled">T</span>`:null}
|
|
3030
3154
|
</button>
|
|
3031
3155
|
`)}
|
|
3032
3156
|
<button class="tree-row add-model" type="button" @click=${()=>{this.addModel(e)}}>
|
|
3033
|
-
${
|
|
3157
|
+
${fw()} <span>Add model</span>
|
|
3034
3158
|
</button>
|
|
3035
3159
|
</div>
|
|
3036
3160
|
`}renderDetail(){let e=this.selection;if(e===void 0)return g`
|
|
@@ -3047,16 +3171,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3047
3171
|
</div>
|
|
3048
3172
|
<div class="provider-actions">
|
|
3049
3173
|
<button type="button" class="secondary" ?disabled=${!r||n?.phase===`discovering`} @click=${()=>{this.discoverModels(e)}}>
|
|
3050
|
-
${n?.phase===`discovering`?
|
|
3174
|
+
${n?.phase===`discovering`?vw():mw()} ${n===void 0?`Fetch models`:n.phase===`discovering`?`Fetching models...`:`Refresh models`}
|
|
3051
3175
|
</button>
|
|
3052
|
-
<button type="button" class="danger" @click=${()=>{this.deleteProvider(e)}}>${
|
|
3176
|
+
<button type="button" class="danger" @click=${()=>{this.deleteProvider(e)}}>${pw()} Delete provider</button>
|
|
3053
3177
|
</div>
|
|
3054
3178
|
</div>
|
|
3055
3179
|
|
|
3056
3180
|
<div class="field-stack provider-name-field">
|
|
3057
3181
|
<label for="provider-name">Provider name</label>
|
|
3058
3182
|
<div class="inline-field">
|
|
3059
|
-
<input id="provider-name" class="mono" .value=${this.providerNameDraft} placeholder="provider-name" @input=${e=>{this.providerNameDraft=
|
|
3183
|
+
<input id="provider-name" class="mono" .value=${this.providerNameDraft} placeholder="provider-name" @input=${e=>{this.providerNameDraft=HC(e),this.renameError=``}}>
|
|
3060
3184
|
<button type="button" class="secondary" ?disabled=${this.providerNameDraft.trim()===``||this.providerNameDraft===e} @click=${()=>{this.renameSelectedProvider(e)}}>Rename</button>
|
|
3061
3185
|
</div>
|
|
3062
3186
|
${this.renameError===``?null:g`<span class="field-error">${this.renameError}</span>`}
|
|
@@ -3064,19 +3188,19 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3064
3188
|
|
|
3065
3189
|
<div class="field-stack">
|
|
3066
3190
|
<label for="provider-base-url">Base URL</label>
|
|
3067
|
-
<input id="provider-base-url" class="mono" .value=${t.baseUrl??``} placeholder="https://api.example.com/v1" @input=${n=>{this.replaceProvider(e,{...t,baseUrl:
|
|
3191
|
+
<input id="provider-base-url" class="mono" .value=${t.baseUrl??``} placeholder="https://api.example.com/v1" @input=${n=>{this.replaceProvider(e,{...t,baseUrl:VC(HC(n))})}}>
|
|
3068
3192
|
</div>
|
|
3069
3193
|
|
|
3070
3194
|
<div class="field-stack">
|
|
3071
3195
|
<label for="provider-api-key">API key source</label>
|
|
3072
|
-
<input id="provider-api-key" class="mono" type="password" autocomplete="off" .value=${t.apiKey??``} placeholder="ENV_VAR_NAME, !command, or literal key" @input=${n=>{this.replaceProvider(e,{...t,apiKey:
|
|
3196
|
+
<input id="provider-api-key" class="mono" type="password" autocomplete="off" .value=${t.apiKey??``} placeholder="ENV_VAR_NAME, !command, or literal key" @input=${n=>{this.replaceProvider(e,{...t,apiKey:VC(HC(n))})}}>
|
|
3073
3197
|
<span class="help-text">Use an environment variable name, prefix a command with <code>!</code>, or configure built-in provider credentials through Authentication.</span>
|
|
3074
3198
|
</div>
|
|
3075
3199
|
|
|
3076
3200
|
<div class="field-stack">
|
|
3077
3201
|
<label for="provider-api">API format</label>
|
|
3078
|
-
<select id="provider-api" .value=${t.api??`openai-completions`} @change=${n=>{this.replaceProvider(e,{...t,api:
|
|
3079
|
-
${
|
|
3202
|
+
<select id="provider-api" .value=${t.api??`openai-completions`} @change=${n=>{this.replaceProvider(e,{...t,api:HC(n)})}}>
|
|
3203
|
+
${SC.map(e=>g`<option value=${e}>${e}</option>`)}
|
|
3080
3204
|
</select>
|
|
3081
3205
|
</div>
|
|
3082
3206
|
|
|
@@ -3091,7 +3215,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3091
3215
|
</div>
|
|
3092
3216
|
</details>
|
|
3093
3217
|
</div>
|
|
3094
|
-
`}renderModelDetail(e,t,n,r){let i=this.modelTests[
|
|
3218
|
+
`}renderModelDetail(e,t,n,r){let i=this.modelTests[tw(e,r)];return g`
|
|
3095
3219
|
<div class="detail-content">
|
|
3096
3220
|
<div class="detail-heading">
|
|
3097
3221
|
<div>
|
|
@@ -3099,35 +3223,35 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3099
3223
|
<h2>${n.id.trim()===``?`New model`:n.id}</h2>
|
|
3100
3224
|
</div>
|
|
3101
3225
|
<div class="model-actions">
|
|
3102
|
-
${i===void 0?null:g`<span class="connection-state ${i.phase}">${
|
|
3226
|
+
${i===void 0?null:g`<span class="connection-state ${i.phase}">${ow(i)}</span>`}
|
|
3103
3227
|
<button type="button" class="secondary" ?disabled=${n.id.trim()===``||i?.phase===`testing`} @click=${()=>{this.testModel(e,r)}}>
|
|
3104
|
-
${i?.phase===`testing`?
|
|
3228
|
+
${i?.phase===`testing`?vw():_w()} ${i?.phase===`testing`?`Testing...`:`Test`}
|
|
3105
3229
|
</button>
|
|
3106
|
-
<button type="button" class="danger" @click=${()=>{this.deleteModel(e,r)}}>${
|
|
3230
|
+
<button type="button" class="danger" @click=${()=>{this.deleteModel(e,r)}}>${pw()} Remove</button>
|
|
3107
3231
|
</div>
|
|
3108
3232
|
</div>
|
|
3109
3233
|
|
|
3110
|
-
${i===void 0?null:g`<div class="connection-detail ${i.phase}">${
|
|
3234
|
+
${i===void 0?null:g`<div class="connection-detail ${i.phase}">${sw(i)}</div>`}
|
|
3111
3235
|
|
|
3112
3236
|
<div class="field-grid two-columns">
|
|
3113
3237
|
${this.renderModelIdField(e,n,r)}
|
|
3114
3238
|
<div class="field-stack">
|
|
3115
3239
|
<label for="model-name">Display name</label>
|
|
3116
|
-
<input id="model-name" .value=${n.name??``} placeholder="Display name" @input=${t=>{this.replaceModel(e,r,{...n,name:
|
|
3240
|
+
<input id="model-name" .value=${n.name??``} placeholder="Display name" @input=${t=>{this.replaceModel(e,r,{...n,name:VC(HC(t))})}}>
|
|
3117
3241
|
</div>
|
|
3118
3242
|
</div>
|
|
3119
3243
|
|
|
3120
3244
|
<div class="field-stack">
|
|
3121
3245
|
<label for="model-api">API override</label>
|
|
3122
|
-
<select id="model-api" .value=${n.api??``} @change=${t=>{this.replaceModel(e,r,{...n,api:
|
|
3246
|
+
<select id="model-api" .value=${n.api??``} @change=${t=>{this.replaceModel(e,r,{...n,api:VC(HC(t))})}}>
|
|
3123
3247
|
<option value="">Inherit provider API</option>
|
|
3124
|
-
${
|
|
3248
|
+
${SC.map(e=>g`<option value=${e}>${e}</option>`)}
|
|
3125
3249
|
</select>
|
|
3126
3250
|
</div>
|
|
3127
3251
|
|
|
3128
3252
|
<div class="switch-row">
|
|
3129
3253
|
${this.renderCheck(`Reasoning / thinking`,n.reasoning===!0,t=>{this.replaceModel(e,r,{...n,reasoning:t||void 0})})}
|
|
3130
|
-
${this.renderCheck(`Image input`,n.input?.includes(`image`)===!0,t=>{this.replaceModel(e,r,{...n,input:t?
|
|
3254
|
+
${this.renderCheck(`Image input`,n.input?.includes(`image`)===!0,t=>{this.replaceModel(e,r,{...n,input:t?qC(n.input):JC(n.input)})})}
|
|
3131
3255
|
</div>
|
|
3132
3256
|
|
|
3133
3257
|
${n.reasoning===!0?g`
|
|
@@ -3137,10 +3261,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3137
3261
|
<span class="section-label">Thinking configuration</span>
|
|
3138
3262
|
<p>Map Pi thinking levels to values accepted by this model, or disable a level.</p>
|
|
3139
3263
|
</div>
|
|
3140
|
-
${this.renderCheck(`DeepSeek thinking compatibility`,
|
|
3264
|
+
${this.renderCheck(`DeepSeek thinking compatibility`,YC(n),t=>{this.replaceModel(e,r,XC(n,t))})}
|
|
3141
3265
|
</div>
|
|
3142
3266
|
<div class="thinking-map">
|
|
3143
|
-
${
|
|
3267
|
+
${CC.map(t=>this.renderThinkingLevel(e,r,n,t))}
|
|
3144
3268
|
</div>
|
|
3145
3269
|
</section>
|
|
3146
3270
|
`:null}
|
|
@@ -3148,11 +3272,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3148
3272
|
<div class="field-grid two-columns">
|
|
3149
3273
|
<div class="field-stack">
|
|
3150
3274
|
<label for="context-window">Context window (tokens)</label>
|
|
3151
|
-
<input id="context-window" type="number" min="0" inputmode="numeric" .value=${
|
|
3275
|
+
<input id="context-window" type="number" min="0" inputmode="numeric" .value=${WC(n.contextWindow)} placeholder="128000" @input=${t=>{this.replaceModel(e,r,{...n,contextWindow:GC(HC(t))})}}>
|
|
3152
3276
|
</div>
|
|
3153
3277
|
<div class="field-stack">
|
|
3154
3278
|
<label for="max-tokens">Max output tokens</label>
|
|
3155
|
-
<input id="max-tokens" type="number" min="0" inputmode="numeric" .value=${
|
|
3279
|
+
<input id="max-tokens" type="number" min="0" inputmode="numeric" .value=${WC(n.maxTokens)} placeholder="16384" @input=${t=>{this.replaceModel(e,r,{...n,maxTokens:GC(HC(t))})}}>
|
|
3156
3280
|
</div>
|
|
3157
3281
|
</div>
|
|
3158
3282
|
|
|
@@ -3179,12 +3303,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3179
3303
|
`}renderModelIdField(e,t,n){let r=this.discoveredModels[e]?.models;if(r===void 0)return g`
|
|
3180
3304
|
<div class="field-stack">
|
|
3181
3305
|
<label for="model-id">Model ID <span aria-hidden="true">*</span></label>
|
|
3182
|
-
<input id="model-id" class="mono" .value=${t.id} placeholder="model-id" @input=${r=>{this.replaceModel(e,n,{...t,id:
|
|
3306
|
+
<input id="model-id" class="mono" .value=${t.id} placeholder="model-id" @input=${r=>{this.replaceModel(e,n,{...t,id:HC(r)})}}>
|
|
3183
3307
|
</div>
|
|
3184
3308
|
`;let i=t.id.trim()===``||r.some(e=>e.id===t.id)?r:[{id:t.id,...t.name===void 0?{}:{name:t.name}},...r];return g`
|
|
3185
3309
|
<div class="field-stack">
|
|
3186
3310
|
<label for="model-id">Model ID <span aria-hidden="true">*</span></label>
|
|
3187
|
-
<select id="model-id" class="mono" .value=${t.id} @change=${t=>{this.selectDiscoveredModel(e,n,
|
|
3311
|
+
<select id="model-id" class="mono" .value=${t.id} @change=${t=>{this.selectDiscoveredModel(e,n,HC(t))}}>
|
|
3188
3312
|
${t.id.trim()===``?g`<option value="" disabled>Select a model</option>`:null}
|
|
3189
3313
|
${i.map(e=>g`<option value=${e.id}>${e.name===void 0?e.id:`${e.name} (${e.id})`}</option>`)}
|
|
3190
3314
|
</select>
|
|
@@ -3198,26 +3322,26 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3198
3322
|
</div>
|
|
3199
3323
|
<label class="custom-thinking">
|
|
3200
3324
|
<span>Custom</span>
|
|
3201
|
-
<input class="mono" .value=${o} placeholder=${r} @focus=${()=>{this.setThinkingLevel(e,t,n,r,`custom`,o||r)}} @input=${i=>{this.setThinkingLevel(e,t,n,r,`custom`,
|
|
3325
|
+
<input class="mono" .value=${o} placeholder=${r} @focus=${()=>{this.setThinkingLevel(e,t,n,r,`custom`,o||r)}} @input=${i=>{this.setThinkingLevel(e,t,n,r,`custom`,HC(i))}}>
|
|
3202
3326
|
</label>
|
|
3203
3327
|
</div>
|
|
3204
3328
|
`}renderCostField(e,t,n,r,i){let a=`cost-${t}`;return g`
|
|
3205
3329
|
<div class="field-stack">
|
|
3206
3330
|
<label for=${a}>${e}</label>
|
|
3207
|
-
<input id=${a} type="number" min="0" step="any" inputmode="decimal" .value=${
|
|
3331
|
+
<input id=${a} type="number" min="0" step="any" inputmode="decimal" .value=${WC(i.cost?.[t])} placeholder="0" @input=${e=>{this.setCost(n,r,i,t,KC(HC(e)))}}>
|
|
3208
3332
|
</div>
|
|
3209
3333
|
`}renderCheck(e,t,n){return g`
|
|
3210
3334
|
<label class="check-row">
|
|
3211
|
-
<input type="checkbox" .checked=${t} @change=${e=>{n(
|
|
3335
|
+
<input type="checkbox" .checked=${t} @change=${e=>{n(UC(e))}}>
|
|
3212
3336
|
<span>${e}</span>
|
|
3213
3337
|
</label>
|
|
3214
3338
|
`}renderJsonField(e,t,n,r){let i=`advanced-${t}`,a=this.advancedErrors[t];return g`
|
|
3215
3339
|
<div class="field-stack">
|
|
3216
3340
|
<label for=${i}>${e} (JSON object)</label>
|
|
3217
|
-
<textarea id=${i} class="mono" rows="4" .value=${
|
|
3341
|
+
<textarea id=${i} class="mono" rows="4" .value=${QC(n)} @change=${e=>{r(HC(e))}}></textarea>
|
|
3218
3342
|
${a===void 0?null:g`<span class="field-error">${a}</span>`}
|
|
3219
3343
|
</div>
|
|
3220
|
-
`}async loadConfig(){let e=++this.loadRequestSequence,t=this.machineId();this.modelDiscoveryRequestSequences.clear(),this.discoveredModels={},this.loading=!0,this.error=``,this.savedMessage=``;try{let n=
|
|
3344
|
+
`}async loadConfig(){let e=++this.loadRequestSequence,t=this.machineId();this.modelDiscoveryRequestSequences.clear(),this.discoveredModels={},this.loading=!0,this.error=``,this.savedMessage=``;try{let n=RC(await this.modelsApi.config(t));if(!this.isCurrentLoad(e,t))return;this.config=n,this.selection=zC(this.selection,n),this.providerNameDraft=this.selection?.type===`provider`?this.selection.providerName:``,this.renameError=``,this.advancedErrors={},this.modelTests={}}catch(n){this.isCurrentLoad(e,t)&&(this.error=`Failed to load models configuration: ${lw(n)}`)}finally{this.isCurrentLoad(e,t)&&(this.loading=!1)}}async saveConfig(){if(this.saving||this.loading)return;let e=this.machineId();this.saving=!0,this.error=``,this.savedMessage=``;try{if(await this.modelsApi.save(this.config,e),e!==this.machineId())return;this.setSavedMessage(`Saved and reloaded models for ${this.machineLabel()}.`),this.onSaved?.()}catch(t){e===this.machineId()&&(this.error=`Failed to save models configuration: ${lw(t)}`)}finally{e===this.machineId()&&(this.saving=!1)}}async testModel(e,t){let n=this.config.providers?.[e],r=n?.models?.[t];if(n===void 0||r===void 0)return;let i=tw(e,t);if(r.id.trim()===``){this.modelTests={...this.modelTests,[i]:{phase:`error`,message:`Model ID is required.`}};return}let a=this.machineId();this.modelTests={...this.modelTests,[i]:{phase:`testing`}};try{let t=await this.modelsApi.test({providerName:e,provider:n,model:r},a);if(a!==this.machineId())return;this.modelTests={...this.modelTests,[i]:t.ok?{phase:`success`,result:t}:aw(t)}}catch(e){a===this.machineId()&&(this.modelTests={...this.modelTests,[i]:{phase:`error`,message:lw(e)}})}}async discoverModels(e){let t=this.config.providers?.[e];if(t===void 0)return;let n=this.nextModelDiscoveryRequest(e),r=this.machineId(),i=this.discoveredModels[e];this.error=``,this.discoveredModels={...this.discoveredModels,[e]:i?.models===void 0?{phase:`discovering`}:{phase:`discovering`,models:i.models}};try{let i=await this.modelsApi.discover({providerName:e,provider:t},r);if(!this.isCurrentModelDiscovery(n,r,e,t))return;this.discoveredModels={...this.discoveredModels,[e]:{phase:`ready`,models:i.models}}}catch(a){if(!this.isCurrentModelDiscovery(n,r,e,t))return;this.discoveredModels=i===void 0?iw(this.discoveredModels,e):{...this.discoveredModels,[e]:i},this.error=`Failed to fetch models for ${e}: ${lw(a)}`}}selectProvider(e){this.selection={type:`provider`,providerName:e},this.providerNameDraft=e,this.renameError=``}selectModel(e,t){this.selection={type:`model`,providerName:e,index:t},this.providerNameDraft=``,this.renameError=``}addCustomProvider(){let e=wC(this.config);this.config=e.config,this.selectProvider(e.providerName)}deleteProvider(e){this.clearProviderDiscovery(e),this.config=DC(this.config,e),this.modelTests=nw(this.modelTests,e);let t=Object.keys(this.config.providers??{})[0];t===void 0?(this.selection=void 0,this.providerNameDraft=``):this.selectProvider(t)}renameSelectedProvider(e){let t=TC(this.config,e,this.providerNameDraft);if(`error`in t){this.renameError=t.error;return}let n=this.providerNameDraft.trim();this.clearProviderDiscovery(e),this.config=t.config,this.modelTests=rw(this.modelTests,e,n),this.selectProvider(n)}replaceProvider(e,t){this.invalidateProviderDiscovery(e),this.config=EC(this.config,e,t),this.modelTests=nw(this.modelTests,e)}addModel(e){let t=this.config.providers?.[e]?.models?.length??0;this.config=OC(this.config,e),this.selectModel(e,t)}deleteModel(e,t){this.config=AC(this.config,e,t),this.modelTests=nw(this.modelTests,e),this.selectProvider(e)}replaceModel(e,t,n){this.config=kC(this.config,e,t,n);let r=tw(e,t);this.modelTests[r]!==void 0&&(this.modelTests=iw(this.modelTests,r))}selectDiscoveredModel(e,t,n){let r=this.config.providers?.[e]?.models?.[t],i=this.discoveredModels[e]?.models?.find(e=>e.id===n);r===void 0||i===void 0||this.replaceModel(e,t,{...r,id:i.id,name:i.name??i.id})}invalidateProviderDiscovery(e){this.nextModelDiscoveryRequest(e);let t=this.discoveredModels[e];if(t?.phase===`discovering`){if(t.models===void 0){this.discoveredModels=iw(this.discoveredModels,e);return}this.discoveredModels={...this.discoveredModels,[e]:{phase:`ready`,models:t.models}}}}clearProviderDiscovery(e){this.nextModelDiscoveryRequest(e),this.discoveredModels[e]!==void 0&&(this.discoveredModels=iw(this.discoveredModels,e))}setThinkingLevel(e,t,n,r,i,a){this.replaceModel(e,t,{...n,thinkingLevelMap:jC(n.thinkingLevelMap,r,i,a)})}setCost(e,t,n,r,i){let a={...n.cost??{},[r]:i};if(Object.values(a).every(e=>e===void 0)){this.replaceModel(e,t,{...n,cost:void 0});return}this.replaceModel(e,t,{...n,cost:a})}updateProviderHeaders(e,t,n){let r=ZC(n),i=`headers`;if(!r.ok){this.setAdvancedError(i,r.error);return}if(r.value!==void 0&&!$C(r.value)){this.setAdvancedError(i,`Headers must map string names to string values.`);return}this.clearAdvancedError(i),this.replaceProvider(e,{...t,headers:r.value===void 0?void 0:ew(r.value)})}updateProviderObject(e,t,n,r){let i=ZC(r),a=n===`compat`?`compat`:`model-overrides`;if(!i.ok){this.setAdvancedError(a,i.error);return}this.clearAdvancedError(a),this.replaceProvider(e,{...t,[n]:i.value})}updateModelObject(e,t,n,r,i){let a=ZC(i),o=`model-compat`;if(!a.ok){this.setAdvancedError(o,a.error);return}this.clearAdvancedError(o),this.replaceModel(e,t,{...n,[r]:a.value})}setAdvancedError(e,t){this.advancedErrors={...this.advancedErrors,[e]:t}}clearAdvancedError(e){this.advancedErrors[e]!==void 0&&(this.advancedErrors=iw(this.advancedErrors,e))}configureAuth(){this.onConfigureAuth?.()}close(){this.onClose?.()}handleKeyDown(e){e.key===`Escape`&&(e.preventDefault(),this.close())}resetForMachineChange(){this.loadRequestSequence+=1,this.modelDiscoveryRequestSequences.clear(),this.config={providers:{}},this.loading=!0,this.saving=!1,this.error=``,this.savedMessage=``,this.selection=void 0,this.providerNameDraft=``,this.renameError=``,this.advancedErrors={},this.modelTests={},this.discoveredModels={}}machineId(){return BC(this.machine)}machineLabel(){let e=this.machine?.name;return e===void 0||e===``?`local machine`:e}isCurrentLoad(e,t){return e===this.loadRequestSequence&&t===this.machineId()}isCurrentModelDiscovery(e,t,n,r){return e===this.modelDiscoveryRequestSequences.get(n)&&t===this.machineId()&&this.config.providers?.[n]===r}nextModelDiscoveryRequest(e){let t=++this.modelDiscoverySequence;return this.modelDiscoveryRequestSequences.set(e,t),t}setSavedMessage(e){this.savedMessageTimer!==void 0&&clearTimeout(this.savedMessageTimer),this.savedMessage=e,this.savedMessageTimer=setTimeout(()=>{this.savedMessage=``,this.savedMessageTimer=void 0},3e3)}static{this.styles=h`
|
|
3221
3345
|
:host { position: fixed; inset: 0; z-index: 9; display: block; color: var(--pi-text); }
|
|
3222
3346
|
.backdrop { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--pi-overlay); }
|
|
3223
3347
|
.dialog { width: min(920px, 100%); height: min(78dvh, 760px); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); }
|
|
@@ -3325,16 +3449,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3325
3449
|
.thinking-row { grid-template-columns: 58px minmax(0, 1fr); }
|
|
3326
3450
|
.custom-thinking { grid-column: 1 / -1; }
|
|
3327
3451
|
}
|
|
3328
|
-
`}};B([x({attribute:!1})],
|
|
3452
|
+
`}};B([x({attribute:!1})],LC.prototype,`machine`,void 0),B([x({attribute:!1})],LC.prototype,`modelsApi`,void 0),B([x({attribute:!1})],LC.prototype,`onClose`,void 0),B([x({attribute:!1})],LC.prototype,`onConfigureAuth`,void 0),B([x({attribute:!1})],LC.prototype,`onSaved`,void 0),B([S()],LC.prototype,`config`,void 0),B([S()],LC.prototype,`loading`,void 0),B([S()],LC.prototype,`saving`,void 0),B([S()],LC.prototype,`error`,void 0),B([S()],LC.prototype,`savedMessage`,void 0),B([S()],LC.prototype,`selection`,void 0),B([S()],LC.prototype,`providerNameDraft`,void 0),B([S()],LC.prototype,`renameError`,void 0),B([S()],LC.prototype,`advancedErrors`,void 0),B([S()],LC.prototype,`modelTests`,void 0),B([S()],LC.prototype,`discoveredModels`,void 0),LC=B([b(`models-config-dialog`)],LC);function RC(e){return e.providers===void 0?{...e,providers:{}}:e}function zC(e,t){if(e?.type===`provider`&&t.providers?.[e.providerName]!==void 0||e?.type===`model`&&t.providers?.[e.providerName]?.models?.[e.index]!==void 0)return e;let n=Object.keys(t.providers??{})[0];return n===void 0?void 0:{type:`provider`,providerName:n}}function BC(e){if(!cw(e))return`local`;let t=e.id;return typeof t==`string`&&t!==``?t:`local`}function VC(e){return e.trim()===``?void 0:e}function HC(e){let t=e.target;return t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement?t.value:``}function UC(e){return e.target instanceof HTMLInputElement&&e.target.checked}function WC(e){return e===void 0?``:String(e)}function GC(e){let t=e.trim();if(t===``)return;let n=Number(t);return Number.isInteger(n)&&n>=0?n:void 0}function KC(e){let t=e.trim();if(t===``)return;let n=Number(t);return Number.isFinite(n)&&n>=0?n:void 0}function qC(e){let t=e??[`text`];return t.includes(`image`)?[...t]:[...t,`image`]}function JC(e){let t=(e??[]).filter(e=>e!==`image`);return t.length===0?void 0:t}function YC(e){return e.compat?.thinkingFormat===`deepseek`}function XC(e,t){if(t)return{...e,compat:{...e.compat??{},...IC}};if(e.compat===void 0)return e;let n={...e.compat};return delete n.thinkingFormat,delete n.requiresReasoningContentOnAssistantMessages,{...e,compat:Object.keys(n).length===0?void 0:n}}function ZC(e){if(e.trim()===``)return{ok:!0,value:void 0};try{let t=JSON.parse(e);return cw(t)?{ok:!0,value:t}:{ok:!1,error:`Value must be a JSON object.`}}catch(e){return{ok:!1,error:`Invalid JSON: ${lw(e)}`}}}function QC(e){return e===void 0?``:JSON.stringify(e,null,2)}function $C(e){return Object.values(e).every(e=>typeof e==`string`)}function ew(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}function tw(e,t){return`${e}\u0000${String(t)}`}function nw(e,t){let n=`${t}\u0000`,r={};for(let[t,i]of Object.entries(e))t.startsWith(n)||(r[t]=i);return r}function rw(e,t,n){let r=`${t}\u0000`,i=`${n}\u0000`,a={};for(let[t,n]of Object.entries(e)){let e=t.startsWith(r)?`${i}${t.slice(r.length)}`:t;a[e]=n}return a}function iw(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function aw(e){return{phase:`error`,message:e.error??`Model returned an error.`,...e.latencyMs===void 0?{}:{latencyMs:e.latencyMs},...e.status===void 0?{}:{status:e.status}}}function ow(e){return e.phase===`testing`?`Testing connection`:e.phase===`success`?e.result.latencyMs===void 0?`Connected`:`Connected in ${String(e.result.latencyMs)} ms`:`Connection failed`}function sw(e){if(e.phase===`testing`)return`Sending a small test request...`;if(e.phase===`success`){let t=[e.result.status===void 0?void 0:`HTTP ${String(e.result.status)}`,e.result.latencyMs===void 0?void 0:`${String(e.result.latencyMs)} ms`,e.result.responseText===void 0||e.result.responseText===``?void 0:e.result.responseText].filter(e=>e!==void 0);return t.length===0?`Connection succeeded.`:t.join(` - `)}return[e.status===void 0?void 0:`HTTP ${String(e.status)}`,e.latencyMs===void 0?void 0:`${String(e.latencyMs)} ms`,e.message].filter(e=>e!==void 0).join(` - `)}function cw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lw(e){return e instanceof Error?e.message:String(e)}function uw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="4" width="16" height="16" rx="2"></rect><rect x="9" y="9" width="6" height="6"></rect><path d="M9 1v3m6-3v3M9 20v3m6-3v3M20 9h3m-3 5h3M1 9h3m-3 5h3"></path></svg>`}function dw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="7"></circle><path d="M12 8v4l3 2"></path></svg>`}function fw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 5v14M5 12h14"></path></svg>`}function pw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7h16M10 11v6m4-6v6M9 7l1-3h4l1 3m-9 0 1 13h10l1-13"></path></svg>`}function mw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M20 11a8 8 0 1 0 2 5.5"></path><path d="M20 4v7h-7"></path></svg>`}function hw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 6 12 12M18 6 6 18"></path></svg>`}function gw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="8" cy="15" r="4"></circle><path d="m11 12 9-9m-3 0h3v3"></path></svg>`}function _w(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 22v-5M8 4v5m8-5v5M7 9h10v3a5 5 0 0 1-10 0V9Z"></path></svg>`}function vw(){return _`<svg class="svg-icon spin" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="8" opacity=".25"></circle><path d="M20 12a8 8 0 0 0-8-8"></path></svg>`}var q=class extends y{constructor(...e){super(...e),this.cwd=``,this.skillsApi=Ya,this.skills=[],this.loading=!0,this.loadError=``,this.togglingPaths=new Set,this.saveError=``,this.addMode=!1,this.searchQuery=``,this.searchResults=[],this.searching=!1,this.searchError=``,this.installError=``,this.newlyInstalledKeys=new Set,this.installScope=`global`,this.updateStatuses={},this.checkingUpdateKeys=new Set,this.checkingAll=!1,this.updateError=``,this.loadRequestSequence=0}connectedCallback(){super.connectedCallback(),this.loadSkills()}updated(e){let t=e.has(`machine`)&&yw(e.get(`machine`))!==this.machineId(),n=e.has(`cwd`)&&e.get(`cwd`)!==this.cwd;(t||n)&&(this.resetForTargetChange(),this.isConnected&&this.loadSkills())}render(){let e=this.selectedSkill();return g`
|
|
3329
3453
|
<div class="backdrop" @mousedown=${e=>{e.target===e.currentTarget&&this.close()}}>
|
|
3330
3454
|
<section class="dialog" role="dialog" aria-modal="true" aria-labelledby="skills-dialog-title" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
3331
3455
|
<header>
|
|
3332
3456
|
<div class="title-block">
|
|
3333
3457
|
<h1 id="skills-dialog-title">Skills</h1>
|
|
3334
|
-
<span class="target"><code>${
|
|
3458
|
+
<span class="target"><code>${Cw(this.cwd)}</code> on ${this.machineLabel()}</span>
|
|
3335
3459
|
</div>
|
|
3336
3460
|
<button class="icon-button" type="button" title="Close skills configuration" aria-label="Close skills configuration" @click=${()=>{this.close()}}>
|
|
3337
|
-
${
|
|
3461
|
+
${Rw()}
|
|
3338
3462
|
</button>
|
|
3339
3463
|
</header>
|
|
3340
3464
|
|
|
@@ -3360,21 +3484,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3360
3484
|
</div>
|
|
3361
3485
|
<div class="skill-list-actions">
|
|
3362
3486
|
<button class="add-skill" type="button" ?aria-pressed=${this.addMode} @click=${()=>{this.openAddMode()}}>
|
|
3363
|
-
${
|
|
3487
|
+
${Lw()} Add skill
|
|
3364
3488
|
</button>
|
|
3365
3489
|
</div>
|
|
3366
3490
|
</aside>
|
|
3367
|
-
`}renderSkillListItem(e){let t=!this.addMode&&e.filePath===this.selectedFilePath,n=
|
|
3491
|
+
`}renderSkillListItem(e){let t=!this.addMode&&e.filePath===this.selectedFilePath,n=Dw(e,this.updateStatuses);return g`
|
|
3368
3492
|
<button class="skill-row ${t?`selected`:``}" type="button" @click=${()=>{this.selectSkill(e)}}>
|
|
3369
3493
|
<span class="skill-indicator ${e.disableModelInvocation?`disabled`:``}" aria-hidden="true"></span>
|
|
3370
3494
|
<span class="skill-name">${e.name}</span>
|
|
3371
3495
|
${n?.state===`update-available`?g`<span class="update-available-mark" title="Update available" aria-label="Update available">↑</span>`:null}
|
|
3372
3496
|
</button>
|
|
3373
|
-
`}renderSkillDetail(e){let t=
|
|
3497
|
+
`}renderSkillDetail(e){let t=xw(e),n=Ew(e),r=n===void 0?void 0:this.updateStatuses[n],i=n!==void 0&&this.checkingUpdateKeys.has(n),a=n!==void 0&&this.updatingKey===n,o=!e.disableModelInvocation;return g`
|
|
3374
3498
|
<div class="detail-content">
|
|
3375
3499
|
<div class="skill-meta-row">
|
|
3376
3500
|
<span class="scope-tag ${t}">${t}</span>
|
|
3377
|
-
<code class="skill-path" title=${e.filePath}>${
|
|
3501
|
+
<code class="skill-path" title=${e.filePath}>${Sw(e,this.cwd)}</code>
|
|
3378
3502
|
<button
|
|
3379
3503
|
class="skill-toggle ${o?`enabled`:``}"
|
|
3380
3504
|
type="button"
|
|
@@ -3392,7 +3516,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3392
3516
|
<section class="detail-section">
|
|
3393
3517
|
<h2>Source</h2>
|
|
3394
3518
|
<a class="source-link" href=${e.install.skillsShUrl} target="_blank" rel="noreferrer" title=${e.install.skillsShUrl}>
|
|
3395
|
-
<code>${
|
|
3519
|
+
<code>${ww(e.install.skillsShUrl)} ↗</code>
|
|
3396
3520
|
</a>
|
|
3397
3521
|
</section>
|
|
3398
3522
|
`}
|
|
@@ -3401,13 +3525,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3401
3525
|
<section class="detail-section">
|
|
3402
3526
|
<h2>Version</h2>
|
|
3403
3527
|
<div class="version-row">
|
|
3404
|
-
<code>${
|
|
3528
|
+
<code>${Tw(r?.currentVersion??e.install.versionHash)}</code>
|
|
3405
3529
|
${e.install.canCheckForUpdates?g`
|
|
3406
3530
|
<button type="button" class="secondary compact-button" ?disabled=${i||a} @click=${()=>{this.checkForUpdates(e)}}>
|
|
3407
3531
|
${i?`Checking...`:`Check`}
|
|
3408
3532
|
</button>
|
|
3409
3533
|
`:null}
|
|
3410
|
-
${r?.state===`update-available`?g`<code class="update-version">${
|
|
3534
|
+
${r?.state===`update-available`?g`<code class="update-version">${Tw(r.latestVersion)}</code>`:null}
|
|
3411
3535
|
${this.renderUpdateStatus(r,i)}
|
|
3412
3536
|
${r?.state===`update-available`?g`
|
|
3413
3537
|
<button type="button" class="primary compact-button" ?disabled=${a||i} @click=${()=>{this.updateInstalledSkill(e)}}>
|
|
@@ -3429,7 +3553,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3429
3553
|
<p>${e.description}</p>
|
|
3430
3554
|
</section>
|
|
3431
3555
|
</div>
|
|
3432
|
-
`}renderUpdateStatus(e,t){if(!t&&(e===void 0||e.state===`update-available`))return null;let n=t?`Checking...`:e?.state===`up-to-date`?`Up to date`:e?.state===`unsupported`?`Automatic checks unavailable`:e?.message??`Check failed`;return g`<span class="update-state ${t?`checking`:e?.state??`error`}">${n}</span>`}renderAddPanel(){let e=this.installScope===`global`?`~/.pi/agent/skills/`:`${
|
|
3556
|
+
`}renderUpdateStatus(e,t){if(!t&&(e===void 0||e.state===`update-available`))return null;let n=t?`Checking...`:e?.state===`up-to-date`?`Up to date`:e?.state===`unsupported`?`Automatic checks unavailable`:e?.message??`Check failed`;return g`<span class="update-state ${t?`checking`:e?.state??`error`}">${n}</span>`}renderAddPanel(){let e=this.installScope===`global`?`~/.pi/agent/skills/`:`${Cw(this.cwd)}/.pi/skills/`;return g`
|
|
3433
3557
|
<div class="detail-content add-panel">
|
|
3434
3558
|
<div class="add-heading">
|
|
3435
3559
|
<h2>Add Skill</h2>
|
|
@@ -3441,7 +3565,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3441
3565
|
id="skill-search"
|
|
3442
3566
|
.value=${this.searchQuery}
|
|
3443
3567
|
placeholder="e.g. react, testing, deploy"
|
|
3444
|
-
@input=${e=>{this.searchQuery=
|
|
3568
|
+
@input=${e=>{this.searchQuery=Pw(e)}}
|
|
3445
3569
|
@keydown=${e=>{e.key===`Enter`&&(e.preventDefault(),this.searchSkills())}}
|
|
3446
3570
|
>
|
|
3447
3571
|
<button type="button" class="primary" ?disabled=${this.searching||this.searchQuery.trim()===``} @click=${()=>{this.searchSkills()}}>
|
|
@@ -3463,7 +3587,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3463
3587
|
|
|
3464
3588
|
${this.searchResults.length>0?g`<div class="search-results">${this.searchResults.map(e=>this.renderSearchResult(e))}</div>`:this.searching||this.searchError!==``?null:g`<p class="search-hint">Search <a href="https://skills.sh" target="_blank" rel="noreferrer">skills.sh</a> to discover and install skills for your agent.</p>`}
|
|
3465
3589
|
</div>
|
|
3466
|
-
`}renderSearchResult(e){let t=this.isInstalled(e.package,this.installScope),n=this.installingPackage===e.package,r=
|
|
3590
|
+
`}renderSearchResult(e){let t=this.isInstalled(e.package,this.installScope),n=this.installingPackage===e.package,r=kw(e.package);return g`
|
|
3467
3591
|
<article class="search-result">
|
|
3468
3592
|
<div class="search-result-copy">
|
|
3469
3593
|
<strong>${r.skill??r.repository}</strong>
|
|
@@ -3492,7 +3616,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3492
3616
|
</div>
|
|
3493
3617
|
<button type="button" class="secondary" @click=${()=>{this.close()}}>Close</button>
|
|
3494
3618
|
</footer>
|
|
3495
|
-
`}async loadSkills(){let e=this.target();if(e===void 0){this.loading=!1,this.loadError=`A selected workspace is required to manage skills.`;return}let t=++this.loadRequestSequence;this.loading=!0,this.loadError=``;try{let n=await this.skillsApi.list(e.cwd,e.machineId);if(!this.isCurrentTarget(e)||t!==this.loadRequestSequence)return;this.skills=n.skills,this.selectedFilePath=
|
|
3619
|
+
`}async loadSkills(){let e=this.target();if(e===void 0){this.loading=!1,this.loadError=`A selected workspace is required to manage skills.`;return}let t=++this.loadRequestSequence;this.loading=!0,this.loadError=``;try{let n=await this.skillsApi.list(e.cwd,e.machineId);if(!this.isCurrentTarget(e)||t!==this.loadRequestSequence)return;this.skills=n.skills,this.selectedFilePath=bw(this.selectedFilePath,n.skills)}catch(n){this.isCurrentTarget(e)&&t===this.loadRequestSequence&&(this.loadError=`Failed to load skills: ${Fw(n)}`)}finally{this.isCurrentTarget(e)&&t===this.loadRequestSequence&&(this.loading=!1)}}async toggleSkill(e){let t=this.target();if(t===void 0||this.togglingPaths.has(e.filePath))return;let n=!e.disableModelInvocation;this.togglingPaths=Aw(this.togglingPaths,e.filePath),this.saveError=``;try{if(await this.skillsApi.toggle({cwd:t.cwd,filePath:e.filePath,disableModelInvocation:n},t.machineId),!this.isCurrentTarget(t))return;this.skills=this.skills.map(t=>t.filePath===e.filePath?{...t,disableModelInvocation:n}:t)}catch(e){this.isCurrentTarget(t)&&(this.saveError=Fw(e))}finally{this.isCurrentTarget(t)&&(this.togglingPaths=Mw(this.togglingPaths,e.filePath))}}async searchSkills(){let e=this.searchQuery.trim();if(e===``||this.searching)return;let t=this.machineId();this.searching=!0,this.searchError=``,this.searchResults=[];try{let n=await this.skillsApi.search({query:e},t);if(t!==this.machineId())return;this.searchResults=n.results,n.results.length===0&&(this.searchError=`No skills found`)}catch(e){t===this.machineId()&&(this.searchError=Fw(e))}finally{t===this.machineId()&&(this.searching=!1)}}async installSkill(e){let t=this.target();if(t===void 0||this.installingPackage!==void 0)return;let n=this.installScope;this.installingPackage=e,this.installError=``;try{if(await this.skillsApi.install({cwd:t.cwd,package:e,scope:n},t.machineId),!this.isCurrentTarget(t))return;this.newlyInstalledKeys=Aw(this.newlyInstalledKeys,Ow(n,e)),await this.loadSkills()}catch(e){this.isCurrentTarget(t)&&(this.installError=Fw(e))}finally{this.isCurrentTarget(t)&&(this.installingPackage=void 0)}}async checkForUpdates(e){let t=this.target();if(t===void 0)return;let n=(e===void 0?this.skills.filter(e=>e.install!==void 0):[e]).flatMap(e=>{let t=Ew(e);return t===void 0?[]:[t]});if(n.length!==0){this.updateError=``,this.checkingUpdateKeys=jw(this.checkingUpdateKeys,n),e===void 0&&(this.checkingAll=!0);try{let n=e?.install,r=await this.skillsApi.check(n===void 0?{cwd:t.cwd}:{cwd:t.cwd,package:n.package,scope:n.scope},t.machineId);if(!this.isCurrentTarget(t))return;let i={...this.updateStatuses};for(let e of r.updates)i[`${e.scope}\0${e.package}`]=e;this.updateStatuses=i}catch(e){this.isCurrentTarget(t)&&(this.updateError=Fw(e))}finally{this.isCurrentTarget(t)&&(this.checkingUpdateKeys=Nw(this.checkingUpdateKeys,n),e===void 0&&(this.checkingAll=!1))}}}async updateInstalledSkill(e){let t=this.target(),n=e.install,r=Ew(e);if(!(t===void 0||n===void 0||r===void 0||this.updatingKey!==void 0)){this.updatingKey=r,this.updateError=``;try{let e=await this.skillsApi.update({cwd:t.cwd,package:n.package,scope:n.scope},t.machineId);if(!this.isCurrentTarget(t)||(await this.loadSkills(),!this.isCurrentTarget(t)))return;let i=e.skill?.install?.versionHash;this.updateStatuses={...this.updateStatuses,[r]:{package:n.package,scope:n.scope,state:`up-to-date`,...i===void 0?{}:{currentVersion:i,latestVersion:i}}}}catch(e){this.isCurrentTarget(t)&&(this.updateError=Fw(e))}finally{this.isCurrentTarget(t)&&(this.updatingKey=void 0)}}}selectSkill(e){this.selectedFilePath=e.filePath,this.addMode=!1,this.saveError=``,this.updateError=``}openAddMode(){this.addMode=!0,this.updateComplete.then(()=>{this.searchInput?.focus()})}selectedSkill(){return this.skills.find(e=>e.filePath===this.selectedFilePath)}skillGroups(){return[{label:`project / skills.sh`,matches:e=>xw(e)===`project`&&e.install?.skillsShUrl!==void 0},{label:`project`,matches:e=>xw(e)===`project`&&e.install?.skillsShUrl===void 0},{label:`global / skills.sh`,matches:e=>xw(e)===`global`&&e.install?.skillsShUrl!==void 0},{label:`global`,matches:e=>xw(e)===`global`&&e.install?.skillsShUrl===void 0},{label:`path`,matches:e=>xw(e)===`path`}].flatMap(e=>{let t=this.skills.filter(e.matches);return t.length===0?[]:[{label:e.label,skills:t}]})}isInstalled(e,t){return this.skills.some(n=>n.install?.scope===t&&n.install.package===e)||this.newlyInstalledKeys.has(Ow(t,e))}target(){return this.cwd===``?void 0:{cwd:this.cwd,machineId:this.machineId()}}isCurrentTarget(e){return e.cwd===this.cwd&&e.machineId===this.machineId()}machineId(){return yw(this.machine)}machineLabel(){let e=this.machine?.name;return e===void 0||e===``?`local machine`:e}handleKeyDown(e){e.key===`Escape`&&(e.preventDefault(),this.close())}close(){this.onClose?.()}resetForTargetChange(){this.loadRequestSequence+=1,this.skills=[],this.loading=!0,this.loadError=``,this.selectedFilePath=void 0,this.togglingPaths=new Set,this.saveError=``,this.addMode=!1,this.searchQuery=``,this.searchResults=[],this.searching=!1,this.searchError=``,this.installingPackage=void 0,this.installError=``,this.newlyInstalledKeys=new Set,this.installScope=`global`,this.updateStatuses={},this.checkingUpdateKeys=new Set,this.checkingAll=!1,this.updatingKey=void 0,this.updateError=``}static{this.styles=h`
|
|
3496
3620
|
:host { position: fixed; inset: 0; z-index: 9; display: block; color: var(--pi-text); }
|
|
3497
3621
|
.backdrop { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--pi-overlay); }
|
|
3498
3622
|
.dialog { width: min(860px, 100%); height: min(78dvh, 760px); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); }
|
|
@@ -3593,16 +3717,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3593
3717
|
.scope-row { align-items: flex-start; flex-direction: column; gap: 6px; }
|
|
3594
3718
|
.search-result { align-items: flex-start; }
|
|
3595
3719
|
}
|
|
3596
|
-
`}};B([x({attribute:!1})],q.prototype,`machine`,void 0),B([x({type:String})],q.prototype,`cwd`,void 0),B([x({attribute:!1})],q.prototype,`skillsApi`,void 0),B([x({attribute:!1})],q.prototype,`onClose`,void 0),B([S()],q.prototype,`skills`,void 0),B([S()],q.prototype,`loading`,void 0),B([S()],q.prototype,`loadError`,void 0),B([S()],q.prototype,`selectedFilePath`,void 0),B([S()],q.prototype,`togglingPaths`,void 0),B([S()],q.prototype,`saveError`,void 0),B([S()],q.prototype,`addMode`,void 0),B([S()],q.prototype,`searchQuery`,void 0),B([S()],q.prototype,`searchResults`,void 0),B([S()],q.prototype,`searching`,void 0),B([S()],q.prototype,`searchError`,void 0),B([S()],q.prototype,`installingPackage`,void 0),B([S()],q.prototype,`installError`,void 0),B([S()],q.prototype,`newlyInstalledKeys`,void 0),B([S()],q.prototype,`installScope`,void 0),B([S()],q.prototype,`updateStatuses`,void 0),B([S()],q.prototype,`checkingUpdateKeys`,void 0),B([S()],q.prototype,`checkingAll`,void 0),B([S()],q.prototype,`updatingKey`,void 0),B([S()],q.prototype,`updateError`,void 0),B([C(`#skill-search`)],q.prototype,`searchInput`,void 0),q=B([b(`skills-config-dialog`)],q);function
|
|
3720
|
+
`}};B([x({attribute:!1})],q.prototype,`machine`,void 0),B([x({type:String})],q.prototype,`cwd`,void 0),B([x({attribute:!1})],q.prototype,`skillsApi`,void 0),B([x({attribute:!1})],q.prototype,`onClose`,void 0),B([S()],q.prototype,`skills`,void 0),B([S()],q.prototype,`loading`,void 0),B([S()],q.prototype,`loadError`,void 0),B([S()],q.prototype,`selectedFilePath`,void 0),B([S()],q.prototype,`togglingPaths`,void 0),B([S()],q.prototype,`saveError`,void 0),B([S()],q.prototype,`addMode`,void 0),B([S()],q.prototype,`searchQuery`,void 0),B([S()],q.prototype,`searchResults`,void 0),B([S()],q.prototype,`searching`,void 0),B([S()],q.prototype,`searchError`,void 0),B([S()],q.prototype,`installingPackage`,void 0),B([S()],q.prototype,`installError`,void 0),B([S()],q.prototype,`newlyInstalledKeys`,void 0),B([S()],q.prototype,`installScope`,void 0),B([S()],q.prototype,`updateStatuses`,void 0),B([S()],q.prototype,`checkingUpdateKeys`,void 0),B([S()],q.prototype,`checkingAll`,void 0),B([S()],q.prototype,`updatingKey`,void 0),B([S()],q.prototype,`updateError`,void 0),B([C(`#skill-search`)],q.prototype,`searchInput`,void 0),q=B([b(`skills-config-dialog`)],q);function yw(e){if(!Iw(e))return`local`;let t=e.id;return typeof t==`string`&&t!==``?t:`local`}function bw(e,t){return e!==void 0&&t.some(t=>t.filePath===e)?e:t[0]?.filePath}function xw(e){let t=e.sourceInfo.source,n=e.sourceInfo.scope;return n===`user`||t===`user`?`global`:n===`project`||t===`project`?`project`:`path`}function Sw(e,t){return xw(e)===`project`&&e.filePath.startsWith(t)?`./${e.filePath.slice(t.length).replace(/^[/\\]/u,``)}`:Cw(e.filePath)}function Cw(e){return e.replace(/^\/(?:Users|home)\/[^/]+/u,`~`)}function ww(e){return e.replace(/^https?:\/\//u,``)}function Tw(e){return e===void 0||e===``?`unknown`:e.slice(0,8)}function Ew(e){return e.install===void 0?void 0:`${e.install.scope}\0${e.install.package}`}function Dw(e,t){let n=Ew(e);return n===void 0?void 0:t[n]}function Ow(e,t){return`${e}\0${t}`}function kw(e){let t=e.lastIndexOf(`@`);return t<0?{repository:e,skill:void 0}:{repository:e.slice(0,t),skill:e.slice(t+1)}}function Aw(e,t){return new Set([...e,t])}function jw(e,t){return new Set([...e,...t])}function Mw(e,t){let n=new Set(e);return n.delete(t),n}function Nw(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function Pw(e){let t=e.target;return t instanceof HTMLInputElement?t.value:``}function Fw(e){return e instanceof Error?e.message:String(e)}function Iw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Lw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 5v14M5 12h14"></path></svg>`}function Rw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 6 12 12M18 6 6 18"></path></svg>`}var J=class extends y{constructor(...e){super(...e),this.cwd=``,this.pluginsApi=eo,this.sessionsApi=io,this.loading=!0,this.loadError=``,this.addMode=!1,this.installSource=``,this.installScope=`global`,this.actionError=``,this.actionMessage=``,this.loadRequestSequence=0}connectedCallback(){super.connectedCallback(),this.loadPlugins()}updated(e){let t=e.has(`machine`)&&Kw(e.get(`machine`))!==this.machineId(),n=e.has(`cwd`)&&e.get(`cwd`)!==this.cwd;!t&&!n||(this.resetForTargetChange(),this.isConnected&&this.loadPlugins())}render(){let e=this.selectedPackage();return g`
|
|
3597
3721
|
<div class="backdrop" @mousedown=${e=>{e.target===e.currentTarget&&this.close()}}>
|
|
3598
3722
|
<section class="dialog" role="dialog" aria-modal="true" aria-labelledby="plugins-dialog-title" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
3599
3723
|
<header>
|
|
3600
3724
|
<div class="title-block">
|
|
3601
3725
|
<h1 id="plugins-dialog-title">Plugins</h1>
|
|
3602
|
-
<span class="target"><code>${
|
|
3726
|
+
<span class="target"><code>${qw(this.cwd)}</code> on ${this.machineLabel()}</span>
|
|
3603
3727
|
</div>
|
|
3604
3728
|
<button class="icon-button" type="button" title="Close Plugins configuration" aria-label="Close Plugins configuration" @click=${()=>{this.close()}}>
|
|
3605
|
-
${
|
|
3729
|
+
${$w()}
|
|
3606
3730
|
</button>
|
|
3607
3731
|
</header>
|
|
3608
3732
|
|
|
@@ -3628,20 +3752,20 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3628
3752
|
</div>
|
|
3629
3753
|
<div class="package-list-actions">
|
|
3630
3754
|
<button class="add-plugin" type="button" aria-pressed=${String(this.addMode)} @click=${()=>{this.openAddMode()}}>
|
|
3631
|
-
${
|
|
3755
|
+
${Qw()} Add plugin
|
|
3632
3756
|
</button>
|
|
3633
3757
|
</div>
|
|
3634
3758
|
</aside>
|
|
3635
|
-
`}renderPackageListItem(e){let t=
|
|
3759
|
+
`}renderPackageListItem(e){let t=zw(e),n=!this.addMode&&t===this.selectedKey;return g`
|
|
3636
3760
|
<button class="package-row ${n?`selected`:``}" type="button" aria-pressed=${String(n)} @click=${()=>{this.selectPackage(e)}}>
|
|
3637
|
-
<span class="package-indicator" style=${`background:${
|
|
3761
|
+
<span class="package-indicator" style=${`background:${Ww(e.status)}`} aria-hidden="true"></span>
|
|
3638
3762
|
<span class="package-copy">
|
|
3639
3763
|
<strong>${e.source}</strong>
|
|
3640
|
-
<small>${
|
|
3641
|
-
${e.version===void 0&&e.configuredVersion===void 0?null:g`<small>${
|
|
3764
|
+
<small>${Hw(e)}</small>
|
|
3765
|
+
${e.version===void 0&&e.configuredVersion===void 0?null:g`<small>${Uw(e)}</small>`}
|
|
3642
3766
|
</span>
|
|
3643
3767
|
</button>
|
|
3644
|
-
`}renderPackageDetail(e){let t=
|
|
3768
|
+
`}renderPackageDetail(e){let t=zw(e),n=this.busyKey?.endsWith(t)??!1,r=this.busyKey===`reload`,i=!e.disabled;return g`
|
|
3645
3769
|
<div class="detail-content">
|
|
3646
3770
|
<div class="detail-heading">
|
|
3647
3771
|
<div class="package-title-row">
|
|
@@ -3673,12 +3797,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3673
3797
|
</div>
|
|
3674
3798
|
|
|
3675
3799
|
<dl class="metadata-grid">
|
|
3676
|
-
<dt>Status</dt><dd style=${`color:${
|
|
3677
|
-
<dt>Version</dt><dd><code>${
|
|
3800
|
+
<dt>Status</dt><dd style=${`color:${Ww(e.status)}`}>${e.status}</dd>
|
|
3801
|
+
<dt>Version</dt><dd><code>${Uw(e)}</code></dd>
|
|
3678
3802
|
<dt>Package</dt><dd><code>${e.packageName??`Unknown`}</code></dd>
|
|
3679
|
-
<dt>Resources</dt><dd>${
|
|
3680
|
-
<dt>Installed path</dt><dd class=${e.installedPath===void 0?`missing`:``}><code>${e.installedPath===void 0?`Not found`:
|
|
3681
|
-
<dt>Workspace</dt><dd><code>${
|
|
3803
|
+
<dt>Resources</dt><dd>${Hw(e)}</dd>
|
|
3804
|
+
<dt>Installed path</dt><dd class=${e.installedPath===void 0?`missing`:``}><code>${e.installedPath===void 0?`Not found`:qw(e.installedPath)}</code></dd>
|
|
3805
|
+
<dt>Workspace</dt><dd><code>${qw(this.cwd)}</code></dd>
|
|
3682
3806
|
</dl>
|
|
3683
3807
|
|
|
3684
3808
|
<section class="resource-section">
|
|
@@ -3707,7 +3831,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3707
3831
|
<div class="detail-content add-panel">
|
|
3708
3832
|
<div class="add-heading">
|
|
3709
3833
|
<h2>Add Plugin</h2>
|
|
3710
|
-
<code>${this.installScope===`project`?`${
|
|
3834
|
+
<code>${this.installScope===`project`?`${qw(this.cwd)}/.pi/agent/{npm,git}`:`~/.pi/agent/{npm,git}`}</code>
|
|
3711
3835
|
</div>
|
|
3712
3836
|
|
|
3713
3837
|
<div class="field-stack">
|
|
@@ -3716,7 +3840,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3716
3840
|
id="plugin-source"
|
|
3717
3841
|
.value=${this.installSource}
|
|
3718
3842
|
placeholder="npm:@scope/package"
|
|
3719
|
-
@input=${e=>{this.installSource=
|
|
3843
|
+
@input=${e=>{this.installSource=Yw(e)}}
|
|
3720
3844
|
@keydown=${t=>{t.key!==`Enter`||this.installSource.trim()===``||e||(t.preventDefault(),this.installPlugin())}}
|
|
3721
3845
|
>
|
|
3722
3846
|
</div>
|
|
@@ -3743,7 +3867,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3743
3867
|
`}renderFooter(){let e=this.data,t=e?.diagnostics??[],n=this.busyKey!==void 0;return g`
|
|
3744
3868
|
<footer>
|
|
3745
3869
|
<div class="footer-summary">
|
|
3746
|
-
${t.length>0?g`<span class=${t.some(e=>e.type===`error`)?`error-message`:`warning-message`} title=${t.map(
|
|
3870
|
+
${t.length>0?g`<span class=${t.some(e=>e.type===`error`)?`error-message`:`warning-message`} title=${t.map(Jw).join(`
|
|
3747
3871
|
`)}>
|
|
3748
3872
|
${String(t.length)} diagnostic${t.length===1?``:`s`}
|
|
3749
3873
|
</span>`:e===void 0?null:g`<span>${String(e.totals.extensions)} ext · ${String(e.totals.skills)} skills · ${String(e.totals.prompts)} prompts · ${String(e.totals.themes)} themes</span>`}
|
|
@@ -3751,7 +3875,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3751
3875
|
<button type="button" class="secondary" ?disabled=${this.loading||n} @click=${()=>{this.loadPlugins()}}>Refresh</button>
|
|
3752
3876
|
<button type="button" class="secondary" @click=${()=>{this.close()}}>Close</button>
|
|
3753
3877
|
</footer>
|
|
3754
|
-
`}async loadPlugins(){let e=this.target();if(e===void 0){this.loading=!1,this.loadError=`A selected workspace is required to manage plugins.`;return}let t=++this.loadRequestSequence;this.loading=!0,this.loadError=``;try{let n=await this.pluginsApi.list(e.cwd,e.machineId);if(!this.isCurrentTarget(e)||t!==this.loadRequestSequence)return;this.data=n,this.addMode=n.packages.length===0||this.addMode,this.selectedKey=
|
|
3878
|
+
`}async loadPlugins(){let e=this.target();if(e===void 0){this.loading=!1,this.loadError=`A selected workspace is required to manage plugins.`;return}let t=++this.loadRequestSequence;this.loading=!0,this.loadError=``;try{let n=await this.pluginsApi.list(e.cwd,e.machineId);if(!this.isCurrentTarget(e)||t!==this.loadRequestSequence)return;this.data=n,this.addMode=n.packages.length===0||this.addMode,this.selectedKey=Bw(this.selectedKey,n.packages)}catch(n){this.isCurrentTarget(e)&&t===this.loadRequestSequence&&(this.loadError=`Failed to load plugins: ${Xw(n)}`)}finally{this.isCurrentTarget(e)&&t===this.loadRequestSequence&&(this.loading=!1)}}async runAction(e,t){let n=this.target();if(n===void 0||this.busyKey!==void 0)return;let r=zw(t);this.busyKey=`${e}:${r}`,this.actionError=``,this.actionMessage=``;try{let r=await this.pluginsApi.mutate({action:e,source:t.source,scope:t.scope,cwd:n.cwd},n.machineId);if(!this.isCurrentTarget(n))return;this.data=r,e===`remove`?(this.selectedKey=Bw(void 0,r.packages),r.packages.length===0&&(this.addMode=!0),this.actionMessage=`Package removed.`):this.actionMessage=Gw(e)}catch(e){this.isCurrentTarget(n)&&(this.actionError=Xw(e))}finally{this.isCurrentTarget(n)&&(this.busyKey=void 0)}}async installPlugin(){let e=this.target(),t=this.installSource.trim();if(e===void 0||t===``||this.busyKey!==void 0)return;let n=this.installScope,r=`${n}\0${t}`;this.busyKey=`install:${r}`,this.actionError=``,this.actionMessage=``;try{let i=await this.pluginsApi.mutate({action:`install`,source:t,scope:n,cwd:e.cwd},e.machineId);if(!this.isCurrentTarget(e))return;this.data=i;let a=Vw(i.packages,t,n);this.selectedKey=a===void 0?r:zw(a),this.addMode=!1,this.installSource=``,this.actionMessage=`Package installed.`}catch(t){this.isCurrentTarget(e)&&(this.actionError=Xw(t))}finally{this.isCurrentTarget(e)&&(this.busyKey=void 0)}}async reloadSession(){let e=this.target(),t=this.session;if(!(e===void 0||t===void 0||this.busyKey!==void 0)){this.busyKey=`reload`,this.actionError=``,this.actionMessage=``;try{let n=await this.sessionsApi.runCommand(t,`/reload`,e.machineId);if(n.type!==`done`)throw Error(n.type===`unsupported`?n.message:`Session runtime reload did not complete.`);if(!this.isCurrentTarget(e)||(await this.onReloaded?.(),await this.loadPlugins(),!this.isCurrentTarget(e)))return;this.actionMessage=`Session reloaded.`}catch(t){this.isCurrentTarget(e)&&(this.actionError=Xw(t))}finally{this.isCurrentTarget(e)&&(this.busyKey=void 0)}}}packageGroups(){let e=this.data?.packages??[];return[`project`,`global`].flatMap(t=>{let n=e.filter(e=>e.scope===t);return n.length===0?[]:[{scope:t,packages:n}]})}selectedPackage(){return(this.data?.packages??[]).find(e=>zw(e)===this.selectedKey)}selectPackage(e){this.selectedKey=zw(e),this.addMode=!1,this.actionError=``,this.actionMessage=``}openAddMode(){this.addMode=!0,this.actionError=``,this.actionMessage=``,this.updateComplete.then(()=>{this.pluginSourceInput?.focus()})}target(){return this.cwd===``?void 0:{cwd:this.cwd,machineId:this.machineId()}}isCurrentTarget(e){return e.cwd===this.cwd&&e.machineId===this.machineId()}machineId(){return Kw(this.machine)}machineLabel(){let e=this.machine?.name;return e===void 0||e===``?`local machine`:e}handleKeyDown(e){e.key===`Escape`&&(e.preventDefault(),this.close())}close(){this.onClose?.()}resetForTargetChange(){this.loadRequestSequence+=1,this.data=void 0,this.loading=!0,this.loadError=``,this.selectedKey=void 0,this.addMode=!1,this.installSource=``,this.installScope=`global`,this.busyKey=void 0,this.actionError=``,this.actionMessage=``}static{this.styles=h`
|
|
3755
3879
|
:host { position: fixed; inset: 0; z-index: 9; display: block; color: var(--pi-text); }
|
|
3756
3880
|
.backdrop { position: absolute; inset: 0; display: grid; box-sizing: border-box; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: var(--pi-overlay); }
|
|
3757
3881
|
.dialog { display: flex; width: min(860px, 100%); height: min(78dvh, 760px); max-height: 100%; flex-direction: column; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); }
|
|
@@ -3853,7 +3977,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3853
3977
|
.package-actions { width: 100%; }
|
|
3854
3978
|
.metadata-grid { grid-template-columns: 96px minmax(0, 1fr); }
|
|
3855
3979
|
}
|
|
3856
|
-
`}};B([x({attribute:!1})],J.prototype,`machine`,void 0),B([x({type:String})],J.prototype,`cwd`,void 0),B([x({attribute:!1})],J.prototype,`session`,void 0),B([x({attribute:!1})],J.prototype,`pluginsApi`,void 0),B([x({attribute:!1})],J.prototype,`sessionsApi`,void 0),B([x({attribute:!1})],J.prototype,`onClose`,void 0),B([x({attribute:!1})],J.prototype,`onReloaded`,void 0),B([S()],J.prototype,`data`,void 0),B([S()],J.prototype,`loading`,void 0),B([S()],J.prototype,`loadError`,void 0),B([S()],J.prototype,`selectedKey`,void 0),B([S()],J.prototype,`addMode`,void 0),B([S()],J.prototype,`installSource`,void 0),B([S()],J.prototype,`installScope`,void 0),B([S()],J.prototype,`busyKey`,void 0),B([S()],J.prototype,`actionError`,void 0),B([S()],J.prototype,`actionMessage`,void 0),B([C(`#plugin-source`)],J.prototype,`pluginSourceInput`,void 0),J=B([b(`plugins-config-dialog`)],J);function
|
|
3980
|
+
`}};B([x({attribute:!1})],J.prototype,`machine`,void 0),B([x({type:String})],J.prototype,`cwd`,void 0),B([x({attribute:!1})],J.prototype,`session`,void 0),B([x({attribute:!1})],J.prototype,`pluginsApi`,void 0),B([x({attribute:!1})],J.prototype,`sessionsApi`,void 0),B([x({attribute:!1})],J.prototype,`onClose`,void 0),B([x({attribute:!1})],J.prototype,`onReloaded`,void 0),B([S()],J.prototype,`data`,void 0),B([S()],J.prototype,`loading`,void 0),B([S()],J.prototype,`loadError`,void 0),B([S()],J.prototype,`selectedKey`,void 0),B([S()],J.prototype,`addMode`,void 0),B([S()],J.prototype,`installSource`,void 0),B([S()],J.prototype,`installScope`,void 0),B([S()],J.prototype,`busyKey`,void 0),B([S()],J.prototype,`actionError`,void 0),B([S()],J.prototype,`actionMessage`,void 0),B([C(`#plugin-source`)],J.prototype,`pluginSourceInput`,void 0),J=B([b(`plugins-config-dialog`)],J);function zw(e){return`${e.scope}\0${e.source}`}function Bw(e,t){return e!==void 0&&t.some(t=>zw(t)===e)?e:t[0]===void 0?void 0:zw(t[0])}function Vw(e,t,n){let r=t.trim(),i=r.startsWith(`npm:`)?r.slice(4):r;return e.find(e=>e.scope===n&&e.source===r)??e.find(e=>e.scope===n&&e.source===`npm:${i}`)??e.find(e=>e.scope===n&&e.installedPath===r)??e.find(e=>e.scope===n&&e.source.endsWith(r))}function Hw(e){if(e.disabled)return`Disabled`;let t=[e.counts.extensions===0?``:`${String(e.counts.extensions)} ext`,e.counts.skills===0?``:`${String(e.counts.skills)} skills`,e.counts.prompts===0?``:`${String(e.counts.prompts)} prompts`,e.counts.themes===0?``:`${String(e.counts.themes)} themes`].filter(e=>e!==``);return t.length===0?`No resources`:t.join(` · `)}function Uw(e){let t=[e.version===void 0?void 0:`installed ${e.version}`,e.configuredVersion===void 0?void 0:`configured ${e.configuredVersion}`].filter(e=>e!==void 0);return t.length===0?`Unknown`:t.join(` · `)}function Ww(e){return e===`loaded`?`var(--pi-accent)`:e===`installed`?`#d97706`:e===`disabled`?`var(--pi-muted)`:`var(--pi-danger)`}function Gw(e){switch(e){case`install`:return`Package installed.`;case`update`:return`Package updated.`;case`disable`:return`Package disabled.`;case`enable`:return`Package enabled.`}}function Kw(e){if(!Zw(e))return`local`;let t=e.id;return typeof t==`string`&&t!==``?t:`local`}function qw(e){return e.replace(/^\/(?:Users|home)\/[^/]+/u,`~`)}function Jw(e){return`${e.type}: ${e.source===void 0?``:`${e.source}: `}${e.message}`}function Yw(e){return e.target instanceof HTMLInputElement?e.target.value:``}function Xw(e){return e instanceof Error?e.message:String(e)}function Zw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Qw(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 5v14M5 12h14"></path></svg>`}function $w(){return _`<svg class="svg-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m6 6 12 12M18 6 6 18"></path></svg>`}var eT=class extends y{constructor(...e){super(...e),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(){let e=++this.requestId;this.loading=!0;try{let t=await L.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`){let t=this.suggestions[this.selected];if(t===void 0)return;e.preventDefault(),this.pick(t)}}render(){return g`
|
|
3857
3981
|
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
3858
3982
|
<section @click=${e=>{e.stopPropagation()}}>
|
|
3859
3983
|
<header>
|
|
@@ -3903,7 +4027,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3903
4027
|
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
3904
4028
|
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
3905
4029
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
3906
|
-
`}};B([x({attribute:!1})],
|
|
4030
|
+
`}};B([x({attribute:!1})],eT.prototype,`onSubmit`,void 0),B([x({attribute:!1})],eT.prototype,`onCancel`,void 0),B([x()],eT.prototype,`machineId`,void 0),B([S()],eT.prototype,`path`,void 0),B([S()],eT.prototype,`createMissing`,void 0),B([S()],eT.prototype,`suggestions`,void 0),B([S()],eT.prototype,`selected`,void 0),B([S()],eT.prototype,`loading`,void 0),B([C(`input`)],eT.prototype,`pathInput`,void 0),eT=B([b(`project-dialog`)],eT);var tT=class extends y{constructor(...e){super(...e),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;let t=e.target.value,n=nT(t);(!this.nameEdited||this.name.trim()===``||this.name===this.previousSuggestedName)&&(this.name=n),this.previousSuggestedName=n,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`&&rT(this.url)===void 0&&(e.preventDefault(),this.updateComplete.then(()=>{this.nameInput?.focus(),this.nameInput?.select()}))}handleSubmit(e){e.preventDefault(),this.submit()}async submit(){let e=this.validInput();if(!(e===void 0||this.submitting)){this.submitting=!0;try{await this.onSubmit?.(e)}finally{this.isConnected&&(this.submitting=!1)}}}validInput(){let e=this.url.trim(),t=this.name.trim();if(e===``||t===``||rT(e)!==void 0)return;let n=this.token.trim();return{name:t,baseUrl:e,...n===``?{}:{token:n}}}render(){let e=this.url.trim()!==``,t=e?rT(this.url):void 0,n=this.validInput()!==void 0&&!this.submitting;return g`
|
|
3907
4031
|
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
3908
4032
|
<section @click=${e=>{e.stopPropagation()}}>
|
|
3909
4033
|
<form @submit=${e=>{this.handleSubmit(e)}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
@@ -3958,7 +4082,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3958
4082
|
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
3959
4083
|
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
3960
4084
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
3961
|
-
`}};B([x({attribute:!1})],
|
|
4085
|
+
`}};B([x({attribute:!1})],tT.prototype,`onSubmit`,void 0),B([x({attribute:!1})],tT.prototype,`onCancel`,void 0),B([x()],tT.prototype,`error`,void 0),B([S()],tT.prototype,`url`,void 0),B([S()],tT.prototype,`name`,void 0),B([S()],tT.prototype,`token`,void 0),B([S()],tT.prototype,`submitting`,void 0),B([C(`input[name='baseUrl']`)],tT.prototype,`urlInput`,void 0),B([C(`input[name='name']`)],tT.prototype,`nameInput`,void 0),tT=B([b(`machine-dialog`)],tT);function nT(e){let t=e.trim();if(t===``)return``;let n=iT(t)??iT(`http://${t.replace(/^\/+/u,``)}`);return n!==void 0&&n.hostname!==``?n.hostname.replace(/^\[(.*)\]$/u,`$1`):aT(t)}function rT(e){let t=e.trim();if(t===``)return`Remote PI WEBUI URL is required.`;let n;try{n=new URL(t)}catch{return`Enter a valid URL including http:// or https://.`}if(n.protocol!==`http:`&&n.protocol!==`https:`)return`Use an http:// or https:// URL.`;if(n.username!==``||n.password!==``)return`Do not include credentials in the machine URL.`;if(n.search!==``||n.hash!==``)return`Do not include a query string or fragment.`}function iT(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`?t:void 0}catch{return}}function aT(e){let t=e.replace(/^[a-z][a-z\d+.-]*:\/\//iu,``),n=t.slice(t.lastIndexOf(`@`)+1).split(/[/?#]/u)[0]??``;return n.startsWith(`[`)&&n.includes(`]`)?n.slice(1,n.indexOf(`]`)):n.replace(/:\d+$/u,``)}var oT={availability:`error`,error:`error`,success:`success`,security:`warning`,warning:`warning`,info:`info`};function sT(e){return e.tone??oT[e.type]}var cT=class extends y{constructor(...e){super(...e),this.heading=``,this.description=``,this.actionLabel=``,this.actionTitle=``,this.actionDisabled=!1,this.notices=[]}render(){return g`
|
|
3962
4086
|
<section class="panel" aria-label=${this.heading||`Settings panel`}>
|
|
3963
4087
|
<header class="section-heading">
|
|
3964
4088
|
<div class="heading-copy">
|
|
@@ -3981,7 +4105,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
3981
4105
|
<div class="notice-stack" aria-label="Settings notices">
|
|
3982
4106
|
${this.notices.map(e=>this.renderNotice(e))}
|
|
3983
4107
|
</div>
|
|
3984
|
-
`}renderNotice(e){let t=
|
|
4108
|
+
`}renderNotice(e){let t=sT(e),n=e.role??lT(t),r=e.title;return g`
|
|
3985
4109
|
<article class=${`notice ${t}`} role=${n}>
|
|
3986
4110
|
${r===void 0||r===``?v:g`<strong class="notice-title">${r}</strong>`}
|
|
3987
4111
|
<div class="notice-content">${e.content}</div>
|
|
@@ -4014,13 +4138,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4014
4138
|
.section-heading { display: grid; gap: 12px; }
|
|
4015
4139
|
.heading-actions { justify-self: start; }
|
|
4016
4140
|
}
|
|
4017
|
-
`}};B([x()],
|
|
4018
|
-
`):``}}function
|
|
4019
|
-
`)??``,uploadDefaultFolder:e.uploads?.defaultFolder??``}}function
|
|
4020
|
-
`).map(e=>e.trim()).filter(e=>e!==``),n=t.find(e=>!
|
|
4141
|
+
`}};B([x()],cT.prototype,`heading`,void 0),B([x({attribute:!1})],cT.prototype,`description`,void 0),B([x()],cT.prototype,`actionLabel`,void 0),B([x()],cT.prototype,`actionTitle`,void 0),B([x({type:Boolean})],cT.prototype,`actionDisabled`,void 0),B([x({attribute:!1})],cT.prototype,`notices`,void 0),B([x({attribute:!1})],cT.prototype,`onAction`,void 0),cT=B([b(`settings-panel-frame`)],cT);function lT(e){switch(e){case`error`:return`alert`;case`success`:return`status`;case`warning`:case`info`:return`note`}}function uT(){return{host:``,port:``,allowedHostsMode:`list`,allowedHostsText:``}}function dT(){return{allowedPathsText:``,uploadDefaultFolder:``}}function fT(){return{command:``,dir:``}}function pT(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(`
|
|
4142
|
+
`):``}}function mT(e){return{allowedPathsText:e.pathAccess?.allowedPaths?.join(`
|
|
4143
|
+
`)??``,uploadDefaultFolder:e.uploads?.defaultFolder??``}}function hT(e){return{command:e.agent?.command??``,dir:e.agent?.dir??``}}function gT(e){let t=e.command.trim(),n=e.dir.trim();return{agent:{...t===``?{}:{command:t},...n===``?{}:{dir:n}}}}function _T(e,t){let n=gT(e).agent??{},r=t.agent??{};return n.command===r.command&&n.dir===r.dir}function vT(e,t={}){let n=bT(t),r=e.host.trim(),i=e.port.trim();if(r!==``&&(n.host=r),i!==``){let e=Number(i);if(!Number.isInteger(e)||e<1||e>65535)throw Error(`Port must be an integer from 1 to 65535.`);n.port=e}return n.allowedHosts=e.allowedHostsMode===`all`||xT(e.allowedHostsText),n}function yT(e){let t=ST(e.allowedPathsText),n=CT(e.uploadDefaultFolder);return{pathAccess:{allowedPaths:t},uploads:n===``?{}:{defaultFolder:n}}}function bT(e){return{...e.shortcuts===void 0?{}:{shortcuts:e.shortcuts},...e.plugins===void 0?{}:{plugins:e.plugins},...e.pathAccess===void 0?{}:{pathAccess:e.pathAccess},...e.uploads===void 0?{}:{uploads:e.uploads},...e.maxUploadBytes===void 0?{}:{maxUploadBytes:e.maxUploadBytes},...e.spawnSessions===void 0?{}:{spawnSessions:e.spawnSessions},...e.subsessions===void 0?{}:{subsessions:e.subsessions},...e.agent===void 0?{}:{agent:e.agent}}}function xT(e){return e.split(/[\n,]/u).map(e=>e.trim()).filter(e=>e!==``)}function ST(e){let t=e.split(`
|
|
4144
|
+
`).map(e=>e.trim()).filter(e=>e!==``),n=t.find(e=>!wT(e));if(n!==void 0)throw Error(`Allowed external paths must be absolute paths or start with ~: ${n}`);return t}function CT(e){let t=e.trim();if(t===``)return``;if(TT(t))throw Error(`Upload default folder must be workspace-relative.`);let n=t.split(/[\\/]+/u).filter(e=>e!==``&&e!==`.`);if(n.length===0)return``;if(n.some(e=>e===`..`))throw Error(`Upload default folder must not contain path traversal.`);return n.join(`/`)}function wT(e){return e===`~`||e.startsWith(`~/`)||e.startsWith(`~\\`)||e.startsWith(`/`)||e.startsWith(`\\`)||/^[A-Za-z]:[\\/]/u.test(e)}function TT(e){let t=e.replace(/\\/g,`/`);return t.startsWith(`/`)||/^[A-Za-z]:\//u.test(t)}function ET(e){return g`Gateway server fields edit this local gateway. File access and upload defaults edit ${e}.`}var Y=class extends y{constructor(...e){super(...e),this.loading=!1,this.machineLoading=!1,this.saving=!1,this.error=``,this.machineError=``,this.savedMessage=``,this.targetLabel=`selected machine`,this.gatewayDraft=uT(),this.machineDraft=dT(),this.gatewayLocalError=``,this.machineLocalError=``}willUpdate(e){e.has(`configResponse`)&&this.configResponse!==void 0&&(this.gatewayDraft=pT(this.configResponse.config),this.gatewayLocalError=``),e.has(`machineConfigResponse`)&&this.machineConfigResponse!==void 0&&(this.machineDraft=mT(this.machineConfigResponse.config),this.machineLocalError=``)}render(){return g`
|
|
4021
4145
|
<settings-panel-frame
|
|
4022
4146
|
heading="General configuration"
|
|
4023
|
-
.description=${
|
|
4147
|
+
.description=${ET(this.targetLabel)}
|
|
4024
4148
|
actionLabel="Reload"
|
|
4025
4149
|
.actionDisabled=${this.loading||this.machineLoading}
|
|
4026
4150
|
.notices=${this.panelNotices()}
|
|
@@ -4049,7 +4173,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4049
4173
|
<span>Host</span>
|
|
4050
4174
|
${this.renderOverrideBadge(`host`)}
|
|
4051
4175
|
</span>
|
|
4052
|
-
<input .value=${this.gatewayDraft.host} placeholder="127.0.0.1" autocomplete="off" spellcheck="false" @input=${e=>{this.updateGatewayDraft({host:
|
|
4176
|
+
<input .value=${this.gatewayDraft.host} placeholder="127.0.0.1" autocomplete="off" spellcheck="false" @input=${e=>{this.updateGatewayDraft({host:kT(e)})}}>
|
|
4053
4177
|
<small>Address the web server should bind to. Leave empty to use PI WEBUI's default.</small>
|
|
4054
4178
|
</label>
|
|
4055
4179
|
|
|
@@ -4058,7 +4182,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4058
4182
|
<span>Port</span>
|
|
4059
4183
|
${this.renderOverrideBadge(`port`)}
|
|
4060
4184
|
</span>
|
|
4061
|
-
<input .value=${this.gatewayDraft.port} inputmode="numeric" pattern="[0-9]*" placeholder="8808" autocomplete="off" @input=${e=>{this.updateGatewayDraft({port:
|
|
4185
|
+
<input .value=${this.gatewayDraft.port} inputmode="numeric" pattern="[0-9]*" placeholder="8808" autocomplete="off" @input=${e=>{this.updateGatewayDraft({port:kT(e)})}}>
|
|
4062
4186
|
<small>TCP port from 1 to 65535. Leave empty to use PI WEBUI's default.</small>
|
|
4063
4187
|
</label>
|
|
4064
4188
|
|
|
@@ -4067,11 +4191,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4067
4191
|
<span>Allowed hosts</span>
|
|
4068
4192
|
${this.renderOverrideBadge(`allowedHosts`)}
|
|
4069
4193
|
</span>
|
|
4070
|
-
<select .value=${this.gatewayDraft.allowedHostsMode} @change=${e=>{this.updateGatewayDraft({allowedHostsMode:
|
|
4194
|
+
<select .value=${this.gatewayDraft.allowedHostsMode} @change=${e=>{this.updateGatewayDraft({allowedHostsMode:AT(e)===`all`?`all`:`list`})}}>
|
|
4071
4195
|
<option value="list">Only listed hosts</option>
|
|
4072
4196
|
<option value="all">Allow every host</option>
|
|
4073
4197
|
</select>
|
|
4074
|
-
<textarea .value=${this.gatewayDraft.allowedHostsText} ?disabled=${this.gatewayDraft.allowedHostsMode===`all`} rows="4" placeholder="example.local 192.168.1.20" spellcheck="false" @input=${e=>{this.updateGatewayDraft({allowedHostsText:
|
|
4198
|
+
<textarea .value=${this.gatewayDraft.allowedHostsText} ?disabled=${this.gatewayDraft.allowedHostsMode===`all`} rows="4" placeholder="example.local 192.168.1.20" spellcheck="false" @input=${e=>{this.updateGatewayDraft({allowedHostsText:jT(e)})}}></textarea>
|
|
4075
4199
|
<small>Enter one host per line, or choose “Allow every host” to write <code>true</code>.</small>
|
|
4076
4200
|
</div>
|
|
4077
4201
|
|
|
@@ -4101,7 +4225,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4101
4225
|
<span class="field-heading">
|
|
4102
4226
|
<span>External filesystem roots</span>
|
|
4103
4227
|
</span>
|
|
4104
|
-
<textarea .value=${this.machineDraft.allowedPathsText} rows="4" placeholder="~/SDKs /opt/reference" spellcheck="false" @input=${e=>{this.updateMachineDraft({allowedPathsText:
|
|
4228
|
+
<textarea .value=${this.machineDraft.allowedPathsText} rows="4" placeholder="~/SDKs /opt/reference" spellcheck="false" @input=${e=>{this.updateMachineDraft({allowedPathsText:jT(e)})}}></textarea>
|
|
4105
4229
|
<small>Allowlist for absolute <code>@</code> completions and file explorer reads outside a workspace on ${this.targetLabel}. Enter one absolute path, Windows absolute path, or <code>~</code>-prefixed path per line. Leave empty to deny external paths by default.</small>
|
|
4106
4230
|
</label>
|
|
4107
4231
|
|
|
@@ -4109,7 +4233,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4109
4233
|
<span class="field-heading">
|
|
4110
4234
|
<span>Default upload folder</span>
|
|
4111
4235
|
</span>
|
|
4112
|
-
<input .value=${this.machineDraft.uploadDefaultFolder} placeholder=${_o} autocomplete="off" spellcheck="false" @input=${e=>{this.updateMachineDraft({uploadDefaultFolder:
|
|
4236
|
+
<input .value=${this.machineDraft.uploadDefaultFolder} placeholder=${_o} autocomplete="off" spellcheck="false" @input=${e=>{this.updateMachineDraft({uploadDefaultFolder:kT(e)})}}>
|
|
4113
4237
|
<small>Workspace-relative folder for manual file uploads on ${this.targetLabel}. Leave empty to use PI WEBUI's default <code>${_o}</code>.</small>
|
|
4114
4238
|
</label>
|
|
4115
4239
|
|
|
@@ -4127,18 +4251,18 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4127
4251
|
<dl>
|
|
4128
4252
|
<div><dt>Host</dt><dd>${e.host??g`<span class="muted">127.0.0.1 default</span>`}</dd></div>
|
|
4129
4253
|
<div><dt>Port</dt><dd>${e.port??g`<span class="muted">8808 default</span>`}</dd></div>
|
|
4130
|
-
<div><dt>Allowed hosts</dt><dd>${
|
|
4254
|
+
<div><dt>Allowed hosts</dt><dd>${DT(e.allowedHosts)}</dd></div>
|
|
4131
4255
|
</dl>
|
|
4132
4256
|
</section>
|
|
4133
4257
|
`}renderMachineEffectiveConfig(){let e=this.machineConfigResponse?.effectiveConfig??{};return g`
|
|
4134
4258
|
<section class="effective-card" aria-label="Effective selected machine file access and upload summary">
|
|
4135
4259
|
<h3>Effective selected-machine settings</h3>
|
|
4136
4260
|
<dl>
|
|
4137
|
-
<div><dt>External roots</dt><dd>${
|
|
4261
|
+
<div><dt>External roots</dt><dd>${OT(e.pathAccess?.allowedPaths)}</dd></div>
|
|
4138
4262
|
<div><dt>Upload folder</dt><dd>${e.uploads?.defaultFolder??g`<span class="muted">${`.pi-webui/uploads`} default</span>`}</dd></div>
|
|
4139
4263
|
</dl>
|
|
4140
4264
|
</section>
|
|
4141
|
-
`}reloadAll(){this.onReload?.(),this.onReloadMachine?.()}async saveGatewayConfig(e){e.preventDefault(),this.gatewayLocalError=``;try{await this.onSave?.(
|
|
4265
|
+
`}reloadAll(){this.onReload?.(),this.onReloadMachine?.()}async saveGatewayConfig(e){e.preventDefault(),this.gatewayLocalError=``;try{await this.onSave?.(vT(this.gatewayDraft,this.configResponse?.config??{}))}catch(e){this.gatewayLocalError=MT(e)}}async saveMachineAccessConfig(e){e.preventDefault(),this.machineLocalError=``;try{await this.onSaveMachineConfig?.(yT(this.machineDraft))}catch(e){this.machineLocalError=MT(e)}}updateGatewayDraft(e){this.gatewayDraft={...this.gatewayDraft,...e},this.gatewayLocalError=``}updateMachineDraft(e){this.machineDraft={...this.machineDraft,...e},this.machineLocalError=``}static{this.styles=h`
|
|
4142
4266
|
:host { display: block; }
|
|
4143
4267
|
.card-heading { display: grid; gap: 6px; min-width: 0; }
|
|
4144
4268
|
h3, p { margin: 0; }
|
|
@@ -4177,10 +4301,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4177
4301
|
@media (max-width: 760px) {
|
|
4178
4302
|
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
4179
4303
|
}
|
|
4180
|
-
`}};B([x({attribute:!1})],Y.prototype,`configResponse`,void 0),B([x({attribute:!1})],Y.prototype,`machineConfigResponse`,void 0),B([x({type:Boolean})],Y.prototype,`loading`,void 0),B([x({type:Boolean})],Y.prototype,`machineLoading`,void 0),B([x({type:Boolean})],Y.prototype,`saving`,void 0),B([x()],Y.prototype,`error`,void 0),B([x()],Y.prototype,`machineError`,void 0),B([x()],Y.prototype,`savedMessage`,void 0),B([x()],Y.prototype,`targetLabel`,void 0),B([x({attribute:!1})],Y.prototype,`onReload`,void 0),B([x({attribute:!1})],Y.prototype,`onReloadMachine`,void 0),B([x({attribute:!1})],Y.prototype,`onSave`,void 0),B([x({attribute:!1})],Y.prototype,`onSaveMachineConfig`,void 0),B([S()],Y.prototype,`gatewayDraft`,void 0),B([S()],Y.prototype,`machineDraft`,void 0),B([S()],Y.prototype,`gatewayLocalError`,void 0),B([S()],Y.prototype,`machineLocalError`,void 0),Y=B([b(`settings-general-panel`)],Y);function
|
|
4304
|
+
`}};B([x({attribute:!1})],Y.prototype,`configResponse`,void 0),B([x({attribute:!1})],Y.prototype,`machineConfigResponse`,void 0),B([x({type:Boolean})],Y.prototype,`loading`,void 0),B([x({type:Boolean})],Y.prototype,`machineLoading`,void 0),B([x({type:Boolean})],Y.prototype,`saving`,void 0),B([x()],Y.prototype,`error`,void 0),B([x()],Y.prototype,`machineError`,void 0),B([x()],Y.prototype,`savedMessage`,void 0),B([x()],Y.prototype,`targetLabel`,void 0),B([x({attribute:!1})],Y.prototype,`onReload`,void 0),B([x({attribute:!1})],Y.prototype,`onReloadMachine`,void 0),B([x({attribute:!1})],Y.prototype,`onSave`,void 0),B([x({attribute:!1})],Y.prototype,`onSaveMachineConfig`,void 0),B([S()],Y.prototype,`gatewayDraft`,void 0),B([S()],Y.prototype,`machineDraft`,void 0),B([S()],Y.prototype,`gatewayLocalError`,void 0),B([S()],Y.prototype,`machineLocalError`,void 0),Y=B([b(`settings-general-panel`)],Y);function DT(e){return e===!0?`Any host`:Array.isArray(e)?e.length===0?g`<span class="muted">None listed</span>`:e.join(`, `):g`<span class="muted">Unset</span>`}function OT(e){return e===void 0||e.length===0?g`<span class="muted">External paths denied</span>`:e.join(`, `)}function kT(e){return e.target instanceof HTMLInputElement?e.target.value:``}function AT(e){return e.target instanceof HTMLSelectElement?e.target.value:``}function jT(e){return e.target instanceof HTMLTextAreaElement?e.target.value:``}function MT(e){return e instanceof Error?e.message:String(e)}function NT(e){return{spawnSessions:e}}function PT(e){return{subsessions:e}}function FT(e,t){let n=e?.effectiveConfig.agent;if(n?.command===void 0||n.dir===void 0||t===void 0)return`unavailable`;let r=[`PI_WEBUI_AGENT_SESSION_DIR`,...jt(n.command)?[`PI_CODING_AGENT_SESSION_DIR`]:[]];return n.command===t.command&&n.dir===t.dir&&RT(t.sessionDirEnvKeys,r)?`active`:`restart-required`}function IT(e,t){return e?.agentDirSource===`pi-webui`?!0:e?.agentDirSource===`pi-compatibility`?jt(t.trim()||`pi`):e?.agentDir===!0}function LT(e,t){let n={...e.envOverrides,spawnSessions:t.envOverrides.spawnSessions,subsessions:t.envOverrides.subsessions,agentCommand:t.envOverrides.agentCommand,agentDir:t.envOverrides.agentDir,agentSessionDir:t.envOverrides.agentSessionDir};return t.envOverrides.agentDirSource===void 0?delete n.agentDirSource:n.agentDirSource=t.envOverrides.agentDirSource,{...e,config:{...e.config,...t.config},effectiveConfig:{...e.effectiveConfig,...t.effectiveConfig},envOverrides:n}}function RT(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var zT=class extends y{constructor(...e){super(...e),this.loading=!1,this.saving=!1,this.error=``,this.savedMessage=``,this.targetLabel=`local (local gateway)`,this.agentProfileSupport={state:`supported`},this.agentDraft=fT(),this.agentDraftDirty=!1,this.agentLocalError=``}willUpdate(e){if(e.has(`configResponse`)){if(this.configResponse===void 0){this.agentDraft=fT(),this.agentDraftDirty=!1,this.agentLocalError=``;return}(!this.agentDraftDirty||_T(this.agentDraft,this.configResponse.config))&&(this.agentDraft=hT(this.configResponse.config),this.agentDraftDirty=!1,this.agentLocalError=``)}}render(){let e=this.configResponse,t=e?.envOverrides.spawnSessions===!0,n=e?.effectiveConfig.spawnSessions!==!1,r=e?.envOverrides.subsessions===!0,i=e?.effectiveConfig.subsessions===!0&&n,a=e?.envOverrides.agentCommand===!0,o=this.agentProfileSupport.state===`supported`,s=a?e.effectiveConfig.agent?.command??this.agentDraft.command:this.agentDraft.command,c=IT(e?.envOverrides,s),l=e?.envOverrides.agentDir===!0,u=e?.effectiveConfig.agent,d=FT(e,this.activeAgentProfile);return g`
|
|
4181
4305
|
<settings-panel-frame
|
|
4182
4306
|
heading="Session daemon"
|
|
4183
|
-
.description=${
|
|
4307
|
+
.description=${UT(this.targetLabel)}
|
|
4184
4308
|
actionLabel="Reload"
|
|
4185
4309
|
.actionDisabled=${this.loading}
|
|
4186
4310
|
.notices=${this.panelNotices(e)}
|
|
@@ -4206,7 +4330,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4206
4330
|
.value=${this.agentDraft.command}
|
|
4207
4331
|
placeholder="pi"
|
|
4208
4332
|
?disabled=${this.loading||this.saving||!o||a}
|
|
4209
|
-
@input=${e=>{this.updateAgentDraft({command:
|
|
4333
|
+
@input=${e=>{this.updateAgentDraft({command:VT(e)})}}
|
|
4210
4334
|
>
|
|
4211
4335
|
<small>Set the Pi-compatible companion CLI used for doctor and update checks. The embedded session runtime remains PI WEBUI's bundled Pi SDK.</small>
|
|
4212
4336
|
</label>
|
|
@@ -4223,7 +4347,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4223
4347
|
.value=${this.agentDraft.dir}
|
|
4224
4348
|
placeholder="~/.pi/agent or ~/agent-profiles/work"
|
|
4225
4349
|
?disabled=${this.loading||this.saving||!o||c}
|
|
4226
|
-
@input=${e=>{this.updateAgentDraft({dir:
|
|
4350
|
+
@input=${e=>{this.updateAgentDraft({dir:VT(e)})}}
|
|
4227
4351
|
>
|
|
4228
4352
|
<small>Choose the Pi-compatible auth, models, settings, and sessions PI WEBUI reads. An alternate command and its required state directory are saved together.</small>
|
|
4229
4353
|
</label>
|
|
@@ -4271,14 +4395,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4271
4395
|
<div><dt>Desired state</dt><dd>${u?.dir??g`<span class="muted">Unavailable</span>`}</dd></div>
|
|
4272
4396
|
<div><dt>Active command</dt><dd>${this.activeAgentProfile?.command??g`<span class="muted">Unavailable</span>`}</dd></div>
|
|
4273
4397
|
<div><dt>Active state</dt><dd>${this.activeAgentProfile?.dir??g`<span class="muted">Unavailable</span>`}</dd></div>
|
|
4274
|
-
<div><dt>Profile status</dt><dd>${
|
|
4398
|
+
<div><dt>Profile status</dt><dd>${BT(d)}</dd></div>
|
|
4275
4399
|
<div><dt>Spawn sessions</dt><dd>${n?`Enabled`:g`<span class="muted">Disabled</span>`}</dd></div>
|
|
4276
4400
|
<div><dt>Subsessions</dt><dd>${i?`Enabled`:g`<span class="muted">Disabled</span>`}</dd></div>
|
|
4277
4401
|
</dl>
|
|
4278
4402
|
</section>
|
|
4279
4403
|
`}
|
|
4280
4404
|
</settings-panel-frame>
|
|
4281
|
-
`}panelNotices(e){return
|
|
4405
|
+
`}panelNotices(e){return WT(e,{error:this.agentLocalError||this.error,savedMessage:this.savedMessage,activeProfile:this.activeAgentProfile,targetLabel:this.targetLabel,profileEditingSupported:this.agentProfileSupport.state===`supported`})}renderUnavailableConfigState(){return g`<div class="loading-card">${this.loading?`Loading configuration…`:`Configuration is unavailable. Reload to try again.`}</div>`}async saveAgentProfile(e){e.preventDefault(),this.agentLocalError=``;try{await this.onSave?.(gT(this.agentDraft))}catch(e){this.agentLocalError=HT(e)}}updateAgentDraft(e){this.agentDraft={...this.agentDraft,...e},this.agentDraftDirty=!0,this.agentLocalError=``}async toggleSpawnSessions(e){let t=e.target instanceof HTMLInputElement&&e.target.checked;await this.onSave?.(NT(t))}async toggleSubsessions(e){let t=e.target instanceof HTMLInputElement&&e.target.checked;await this.onSave?.(PT(t))}static{this.styles=h`
|
|
4282
4406
|
:host { display: block; }
|
|
4283
4407
|
h3 { margin: 0; font-size: 13px; line-height: 1.3; }
|
|
4284
4408
|
button, input { font: inherit; }
|
|
@@ -4324,10 +4448,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4324
4448
|
@media (max-width: 760px) {
|
|
4325
4449
|
.effective-card dl > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
|
4326
4450
|
}
|
|
4327
|
-
`}};B([x({attribute:!1})],
|
|
4451
|
+
`}};B([x({attribute:!1})],zT.prototype,`configResponse`,void 0),B([x({type:Boolean})],zT.prototype,`loading`,void 0),B([x({type:Boolean})],zT.prototype,`saving`,void 0),B([x()],zT.prototype,`error`,void 0),B([x()],zT.prototype,`savedMessage`,void 0),B([x()],zT.prototype,`targetLabel`,void 0),B([x({attribute:!1})],zT.prototype,`activeAgentProfile`,void 0),B([x({attribute:!1})],zT.prototype,`agentProfileSupport`,void 0),B([x({attribute:!1})],zT.prototype,`onReload`,void 0),B([x({attribute:!1})],zT.prototype,`onSave`,void 0),B([S()],zT.prototype,`agentDraft`,void 0),B([S()],zT.prototype,`agentDraftDirty`,void 0),B([S()],zT.prototype,`agentLocalError`,void 0),zT=B([b(`settings-sessiond-panel`)],zT);function BT(e){return e===`active`?`Active`:e===`restart-required`?`Restart required`:g`<span class="muted">Unavailable</span>`}function VT(e){return e.target instanceof HTMLInputElement?e.target.value:``}function HT(e){return e instanceof Error?e.message:String(e)}function UT(e){return`Select the Pi-compatible agent profile and companion CLI for ${e}. Changes are saved immediately but only take effect after the session daemon on that machine restarts.`}function WT(e,t){let n=[];t.error!==``&&n.push({type:`error`,content:t.error}),t.savedMessage!==``&&n.push({type:`success`,content:t.savedMessage});let r=FT(e,t.activeProfile);return r===`restart-required`?n.push({type:`warning`,title:`Pi-compatible agent profile restart required on ${t.targetLabel}`,content:g`The desired profile differs from the active session-daemon profile. Run <code>pi-webui restart</code> on that machine (or restart its session daemon service) to apply the command and state directory together.`}):e!==void 0&&r===`unavailable`&&t.profileEditingSupported&&n.push({type:`info`,title:`Active Pi-compatible agent profile unavailable on ${t.targetLabel}`,content:`PI WEBUI cannot compare the desired profile with the running session daemon. Reload after the daemon is available.`}),n}function GT(e){return e===void 0?{id:`local`,name:`local`,kind:`local`}:{id:e.id,name:e.name,kind:e.kind}}function KT(e){return e.kind===`local`?`${e.name} (local gateway)`:`${e.name} (remote machine)`}function qT(e,t){return e.kind===`local`?{state:`supported`}:t?.ok===!0?Gt(t,T.piPackagesManage)?{state:`supported`}:{state:`unsupported`,message:XT(e)}:{state:`unknown`}}function JT(e){return`${e.state}:${e.message??``}`}function YT(e){return e?.state===`unsupported`}function XT(e){return`Pi package management is not available on ${e.name}. Update and restart Pi-Web on that machine, then try again.`}function ZT(e){return e.kind===`local`}function QT(e){return e.trim()}function $T(e){if(QT(e)===``)return`Enter a Pi package source accepted by Pi, such as npm:@scope/package, a git/URL source, or a local path.`}function eE(e){return e.scope===`project`?`Project scope`:`User scope`}function tE(e){return e.filtered?`Filtered by current Pi package settings`:`Available in this PI WEBUI process`}function nE(e){return e.installedPath??`Installed path not reported by Pi`}function rE(e){return e.scope===`user`}function iE(e){if(!rE(e))return`Project-scope Pi packages are listed for visibility, but PI WEBUI only updates user-scope Pi packages safely from this view.`}function aE(e){return e.length>0&&e.every(rE)}function oE(e){if(e.length===0)return`No Pi packages are configured yet.`;if(!aE(e))return`Update all is disabled while project-scope Pi packages are listed; update user-scope packages individually.`}function sE(e,t,n){return e?.kind===t?n===void 0||e.source===n:!1}function cE(e,t=GT(void 0)){return`Pi package ${e===`install`?`installed`:e===`remove`?`removed`:`updated`}${t.kind===`local`?``:` on ${t.name}`}. Type /reload in ${t.kind===`local`?`each idle PI WEBUI session`:`each idle PI WEBUI session on ${t.name}`} to rediscover Pi runtime resources: extensions, skills, prompt templates, themes, and context/system prompt files. Reload the browser page separately for ${t.kind===`local`?`PI WEBUI browser plugin changes`:`PI WEBUI browser plugin changes served by ${t.name}`}.`}function lE(e,t){let n=e.trim();return t.kind===`remote`?uE(n)?XT(t):n===`Remote machine timeout`?`Timed out while contacting ${t.name} for Pi package management. The package operation may still be running remotely; reload the package list before retrying.`:n===`Remote machine unavailable`?`Could not reach ${t.name} for Pi package management. Check the machine connection and try again.`:n:n}function uE(e){return e===`Not Found`||/route\s+(GET|POST):?\/api\/pi-packages\b.*not found/iu.test(e)||/cannot\s+(GET|POST)\s+.*\/api\/pi-packages\b/iu.test(e)}var dE=class extends y{constructor(...e){super(...e),this.loading=!1,this.error=``,this.operationMessage=``,this.installSource=``,this.validationMessage=``}render(){let e=this.packagesResponse?.packages??[],t=this.packageTarget,n=KT(t),r=this.packageManagementUnavailable,i=this.packagesResponse!==void 0&&!r;return g`
|
|
4328
4452
|
<settings-panel-frame
|
|
4329
4453
|
heading="Pi packages"
|
|
4330
|
-
.description=${
|
|
4454
|
+
.description=${fE(n)}
|
|
4331
4455
|
actionLabel="Reload"
|
|
4332
4456
|
actionTitle=${r?this.packageManagementUnavailableMessage(n):`Reload Pi packages from ${n}`}
|
|
4333
4457
|
.actionDisabled=${this.loading||this.isOperating||r}
|
|
@@ -4344,12 +4468,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4344
4468
|
<label for="package-source">Pi package source</label>
|
|
4345
4469
|
<div class="install-row">
|
|
4346
4470
|
<input id="package-source" .value=${this.installSource} ?disabled=${this.isOperating} placeholder="npm:@scope/package, git URL, or local path" @input=${e=>{this.updateInstallSource(e)}}>
|
|
4347
|
-
<button type="submit" title="Install this Pi package" ?disabled=${this.isOperating}>${
|
|
4471
|
+
<button type="submit" title="Install this Pi package" ?disabled=${this.isOperating}>${sE(this.operation,`install`)?`Installing…`:`Install`}</button>
|
|
4348
4472
|
</div>
|
|
4349
4473
|
${this.validationMessage===``?null:g`<div class="field-error">${this.validationMessage}</div>`}
|
|
4350
4474
|
<small>Installs run on ${e} and use Pi's default package location, equivalent to <code>pi install <source></code>. PI WEBUI does not ask you to choose an install location.</small>
|
|
4351
4475
|
</form>
|
|
4352
|
-
`}renderPackageList(e,t){let n=
|
|
4476
|
+
`}renderPackageList(e,t){let n=KT(t),r=this.packageManagementUnavailable?this.packageManagementUnavailableMessage(n):oE(e),i=r!==void 0&&e.length>0;return g`
|
|
4353
4477
|
<section class="package-section" aria-label="Configured Pi packages">
|
|
4354
4478
|
<div class="package-toolbar">
|
|
4355
4479
|
<div>
|
|
@@ -4357,7 +4481,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4357
4481
|
<p>This list comes from Pi's package manager settings on ${n}.</p>
|
|
4358
4482
|
</div>
|
|
4359
4483
|
<button class="secondary" title=${r??`Update all user-scope Pi packages`} ?disabled=${this.isOperating||r!==void 0} @click=${()=>{this.updatePackage()}}>
|
|
4360
|
-
${
|
|
4484
|
+
${sE(this.operation,`update-all`)?`Updating…`:`Update all`}
|
|
4361
4485
|
</button>
|
|
4362
4486
|
</div>
|
|
4363
4487
|
${i?g`<div class="action-note">${r}</div>`:null}
|
|
@@ -4368,12 +4492,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4368
4492
|
<div class="package-list">
|
|
4369
4493
|
${e.map(e=>this.renderPackage(e))}
|
|
4370
4494
|
</div>
|
|
4371
|
-
`}renderPackage(e){let t=
|
|
4495
|
+
`}renderPackage(e){let t=KT(this.packageTarget),n=this.packageManagementUnavailable,r=n?this.packageManagementUnavailableMessage(t):iE(e),i=n?this.packageManagementUnavailableMessage(t):`Remove this Pi package`,a=sE(this.operation,`update`,e.source),o=sE(this.operation,`remove`,e.source);return g`
|
|
4372
4496
|
<article class=${`package-card${e.filtered?` filtered`:``}`}>
|
|
4373
4497
|
<div class="package-main">
|
|
4374
4498
|
<strong>${e.source}</strong>
|
|
4375
|
-
<small>${
|
|
4376
|
-
<small>Installed path: <code>${
|
|
4499
|
+
<small>${eE(e)} · ${tE(e)}</small>
|
|
4500
|
+
<small>Installed path: <code>${nE(e)}</code></small>
|
|
4377
4501
|
${r===void 0?null:g`<small class="action-note">${r}</small>`}
|
|
4378
4502
|
</div>
|
|
4379
4503
|
<div class="package-actions">
|
|
@@ -4381,7 +4505,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4381
4505
|
<button class="danger" title=${i} ?disabled=${this.isOperating||n} @click=${()=>{this.removePackage(e)}}>${o?`Removing…`:`Remove`}</button>
|
|
4382
4506
|
</div>
|
|
4383
4507
|
</article>
|
|
4384
|
-
`}updateInstallSource(e){this.installSource=e.target instanceof HTMLInputElement?e.target.value:``,this.validationMessage=``}async installPackage(e){e.preventDefault();let t
|
|
4508
|
+
`}updateInstallSource(e){this.installSource=e.target instanceof HTMLInputElement?e.target.value:``,this.validationMessage=``}async installPackage(e){e.preventDefault();let t=$T(this.installSource);if(t!==void 0){this.validationMessage=t;return}let n=QT(this.installSource);try{await this.onInstallPackage?.(n),this.installSource=``,this.validationMessage=``}catch{}}async removePackage(e){try{await this.onRemovePackage?.(e.source,e.scope)}catch{}}async updatePackage(e){try{await this.onUpdatePackage?.(e)}catch{}}get packageTarget(){return this.targetMachine??GT(void 0)}get packageManagementUnavailable(){return YT(this.managementSupport)}packageManagementUnavailableMessage(e){return this.managementSupport?.message??`Pi package management is not available on ${e}.`}get isOperating(){return this.operation!==void 0}static{this.styles=h`
|
|
4385
4509
|
:host { display: block; }
|
|
4386
4510
|
.package-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
|
4387
4511
|
.package-toolbar > div, .package-main { display: grid; gap: 6px; min-width: 0; }
|
|
@@ -4416,10 +4540,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4416
4540
|
.package-actions { justify-self: start; flex-wrap: wrap; }
|
|
4417
4541
|
.package-main strong, .package-main small { white-space: normal; }
|
|
4418
4542
|
}
|
|
4419
|
-
`}};B([x({attribute:!1})],
|
|
4543
|
+
`}};B([x({attribute:!1})],dE.prototype,`packagesResponse`,void 0),B([x({type:Boolean})],dE.prototype,`loading`,void 0),B([x({attribute:!1})],dE.prototype,`operation`,void 0),B([x({attribute:!1})],dE.prototype,`targetMachine`,void 0),B([x({attribute:!1})],dE.prototype,`managementSupport`,void 0),B([x()],dE.prototype,`error`,void 0),B([x()],dE.prototype,`operationMessage`,void 0),B([x({attribute:!1})],dE.prototype,`onReload`,void 0),B([x({attribute:!1})],dE.prototype,`onInstallPackage`,void 0),B([x({attribute:!1})],dE.prototype,`onRemovePackage`,void 0),B([x({attribute:!1})],dE.prototype,`onUpdatePackage`,void 0),B([S()],dE.prototype,`installSource`,void 0),B([S()],dE.prototype,`validationMessage`,void 0),dE=B([b(`settings-packages-panel`)],dE);function fE(e){return g`Managing Pi packages on <strong>${e}</strong>. Install, remove, and update packages managed by Pi on the selected machine. Pi packages can provide extensions, skills, prompt templates, themes, context/system prompt files, and PI WEBUI browser plugins.`}var pE=class extends y{constructor(...e){super(...e),this.loading=!1,this.saving=!1,this.error=``,this.savedMessage=``,this.targetLabel=`local (local gateway)`}render(){let e=this.pluginsResponse?.plugins??[],t=this.pluginsResponse!==void 0;return g`
|
|
4420
4544
|
<settings-panel-frame
|
|
4421
4545
|
heading="PI WEBUI plugins"
|
|
4422
|
-
.description=${
|
|
4546
|
+
.description=${mE(this.targetLabel)}
|
|
4423
4547
|
actionLabel="Reload"
|
|
4424
4548
|
actionTitle=${`Reload PI WEBUI plugins from ${this.targetLabel}`}
|
|
4425
4549
|
.actionDisabled=${this.loading}
|
|
@@ -4465,10 +4589,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4465
4589
|
.plugin-card { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
4466
4590
|
.toggle { justify-self: start; }
|
|
4467
4591
|
}
|
|
4468
|
-
`}};B([x({attribute:!1})],
|
|
4592
|
+
`}};B([x({attribute:!1})],pE.prototype,`pluginsResponse`,void 0),B([x({attribute:!1})],pE.prototype,`configResponse`,void 0),B([x({type:Boolean})],pE.prototype,`loading`,void 0),B([x({type:Boolean})],pE.prototype,`saving`,void 0),B([x()],pE.prototype,`error`,void 0),B([x()],pE.prototype,`savedMessage`,void 0),B([x()],pE.prototype,`targetLabel`,void 0),B([x({attribute:!1})],pE.prototype,`onReload`,void 0),B([x({attribute:!1})],pE.prototype,`onTogglePlugin`,void 0),pE=B([b(`settings-plugins-panel`)],pE);function mE(e){return g`Enable or disable discovered PI WEBUI browser plugins on <strong>${e}</strong>. This is separate from installing Pi packages. Reload the browser tab to apply plugin runtime changes.`}var hE={capture:!0},gE=[{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.`}];function _E(){return g`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.`}var vE=class extends y{constructor(...e){super(...e),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=>{let t=this.recording;if(t===void 0)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){this.stopRecording();return}let n=uf(e);if(n===void 0){this.localError=`Press a letter, number, punctuation, function, or navigation key. Press Esc to cancel recording.`;return}if(t.tokens.length===0&&!df(n)){this.localError=`Start shortcuts with Ctrl/⌘ or Alt so normal typing is not captured.`;return}let r=[...t.tokens,n];this.localError=``,this.drafts={[t.actionId]:r.join(` `)},this.recording={actionId:t.actionId,tokens:r},this.armRecordingTimer()}}willUpdate(e){e.has(`configResponse`)&&this.configResponse!==void 0&&(this.drafts={},this.localError=``,this.stopRecording())}disconnectedCallback(){this.stopRecording(),super.disconnectedCallback()}render(){let e=SE(this.actions),t=this.shortcutResolutions();return g`
|
|
4469
4593
|
<settings-panel-frame
|
|
4470
4594
|
heading="Keyboard shortcuts"
|
|
4471
|
-
.description=${
|
|
4595
|
+
.description=${_E()}
|
|
4472
4596
|
actionLabel="Reload"
|
|
4473
4597
|
.actionDisabled=${this.loading}
|
|
4474
4598
|
.notices=${this.panelNotices()}
|
|
@@ -4499,7 +4623,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4499
4623
|
<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>
|
|
4500
4624
|
</div>
|
|
4501
4625
|
<div class="prompt-enter-options" role="radiogroup" aria-label="Enter and Shift Enter behavior in the chat composer">
|
|
4502
|
-
${
|
|
4626
|
+
${gE.map(e=>g`
|
|
4503
4627
|
<label class="prompt-enter-option">
|
|
4504
4628
|
<input
|
|
4505
4629
|
type="radio"
|
|
@@ -4516,8 +4640,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4516
4640
|
`)}
|
|
4517
4641
|
</div>
|
|
4518
4642
|
</section>
|
|
4519
|
-
`}updatePromptEnterPreference(e){this.promptEnterPreference=e,
|
|
4520
|
-
<article class=${
|
|
4643
|
+
`}updatePromptEnterPreference(e){this.promptEnterPreference=e,zS(e)}renderShortcutRow(e,t){let n=this.configResponse?.config.shortcuts,r=wE(e.id,n),i=DE(e,n),a=this.shortcutInputText(e),o=a.trim()===``?void 0:sf(a),s=o?.ok===!0?o.shortcut:EE(e,n),c=r!==void 0,l=this.drafts[e.id]!==void 0,u=l&&a.trim()!==``?`custom`:i,d=this.recordingHint(e.id),f=xE(t);return g`
|
|
4644
|
+
<article class=${yE(t)}>
|
|
4521
4645
|
<div class="shortcut-main">
|
|
4522
4646
|
<strong>${e.title}</strong>
|
|
4523
4647
|
${e.description!==void 0&&e.description!==``?g`<small>${e.description}</small>`:null}
|
|
@@ -4527,8 +4651,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4527
4651
|
<div class="shortcut-editor">
|
|
4528
4652
|
<div class="shortcut-status">
|
|
4529
4653
|
${s!==void 0&&s!==``?g`<kbd>${lf(s)}</kbd>`:g`<span class="unassigned">${i===`disabled`?`Disabled`:`Unassigned`}</span>`}
|
|
4530
|
-
<small class=${u}>${
|
|
4531
|
-
${f===void 0?null:g`<small class=${
|
|
4654
|
+
<small class=${u}>${OE(u)}${l?` · Unsaved`:``}</small>
|
|
4655
|
+
${f===void 0?null:g`<small class=${bE(t)}>${f}</small>`}
|
|
4532
4656
|
</div>
|
|
4533
4657
|
<label class="shortcut-input-label">
|
|
4534
4658
|
<span>Shortcut</span>
|
|
@@ -4541,7 +4665,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4541
4665
|
autocapitalize="off"
|
|
4542
4666
|
spellcheck="false"
|
|
4543
4667
|
?disabled=${this.saving}
|
|
4544
|
-
@input=${t=>{this.updateDraft(e.id,
|
|
4668
|
+
@input=${t=>{this.updateDraft(e.id,kE(t))}}
|
|
4545
4669
|
>
|
|
4546
4670
|
</label>
|
|
4547
4671
|
${d===``?null:g`<small class="recording-hint">${d}</small>`}
|
|
@@ -4553,7 +4677,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4553
4677
|
</div>
|
|
4554
4678
|
</div>
|
|
4555
4679
|
</article>
|
|
4556
|
-
`}shortcutInputText(e){let t=this.drafts[e.id];if(t!==void 0)return t;let n=
|
|
4680
|
+
`}shortcutInputText(e){let t=this.drafts[e.id];if(t!==void 0)return t;let n=wE(e.id,this.configResponse?.config.shortcuts);return n===null?``:n??e.shortcut??``}recordingHint(e){let t=this.recording;return t?.actionId===e?t.tokens.length===0?`Recording: press Ctrl/⌘ or Alt with a key. Press Esc to cancel.`:`Recording: ${lf(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();let t=sf(this.shortcutInputText(e).trim());if(!t.ok){this.localError=t.message;return}this.localError=``,await this.saveShortcutPreference(e.id,t.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){let n={...this.configResponse?.config??{}},r=n.shortcuts??{},i=t===void 0?TE(r,e):{...r,[e]:t};Object.keys(i).length===0?delete n.shortcuts:n.shortcuts=i,await this.onSave?.(n)}shortcutResolutions(){return new Map(of(this.actions,this.previewShortcutConfig(),{enabledOnly:!0}).map(e=>[e.action.id,e]))}previewShortcutConfig(){let e={...this.configResponse?.config.shortcuts??{}};for(let[t,n]of Object.entries(this.drafts)){let r=n.trim();if(r===``)continue;let i=sf(r);i.ok&&(e[t]=i.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(let 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()},nf)}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,hE),!0)}removeRecordingListener(){this.recordingListenerActive&&=(window.removeEventListener(`keydown`,this.onRecordKeyDown,hE),!1)}static{this.styles=h`
|
|
4557
4681
|
:host { display: block; }
|
|
4558
4682
|
h3, p { margin: 0; }
|
|
4559
4683
|
h3 { font-size: 13px; line-height: 1.3; }
|
|
@@ -4609,7 +4733,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4609
4733
|
.shortcut-row { grid-template-columns: minmax(0, 1fr); align-items: start; }
|
|
4610
4734
|
.shortcut-status, .shortcut-actions { justify-content: flex-start; }
|
|
4611
4735
|
}
|
|
4612
|
-
`}};B([x({attribute:!1})],
|
|
4736
|
+
`}};B([x({attribute:!1})],vE.prototype,`actions`,void 0),B([x({attribute:!1})],vE.prototype,`configResponse`,void 0),B([x({type:Boolean})],vE.prototype,`loading`,void 0),B([x({type:Boolean})],vE.prototype,`saving`,void 0),B([x()],vE.prototype,`error`,void 0),B([x()],vE.prototype,`savedMessage`,void 0),B([x({attribute:!1})],vE.prototype,`onReload`,void 0),B([x({attribute:!1})],vE.prototype,`onSave`,void 0),B([S()],vE.prototype,`drafts`,void 0),B([S()],vE.prototype,`localError`,void 0),B([S()],vE.prototype,`promptEnterPreference`,void 0),B([S()],vE.prototype,`recording`,void 0),vE=B([b(`settings-shortcuts-panel`)],vE);function yE(e){return e?.active===!1?`shortcut-row shadowed`:e?.active===!0&&e.shadows.length>0?`shortcut-row shadowing`:`shortcut-row`}function bE(e){return e?.active===!1?`conflict shadowed`:`conflict shadowing`}function xE(e){if(e===void 0)return;if(!e.active)return`Shadowed by ${e.shadowedBy?.action.title??`another action`}`;let t=e.shadows.length;if(t===0)return;let n=e.shadows.slice(0,2).map(e=>e.action.title).join(`, `),r=t>2?`, +${String(t-2)} more`:``;return`Shadows ${String(t)} ${t===1?`action`:`actions`}: ${n}${r}`}function SE(e){let t=new Map;for(let n of[...e].sort(CE)){let e=n.group??`Other`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>({name:e,actions:t}))}function CE(e,t){return(e.group??`Other`).localeCompare(t.group??`Other`)||e.title.localeCompare(t.title)}function wE(e,t){if(!(t===void 0||!Object.hasOwn(t,e)))return t[e]}function TE(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function EE(e,t){let n=wE(e.id,t);if(n!==null)return n??e.shortcut}function DE(e,t){let n=wE(e.id,t);return n===null?`disabled`:n===void 0?e.shortcut===void 0||e.shortcut===``?`unassigned`:`default`:`custom`}function OE(e){switch(e){case`default`:return`Default`;case`custom`:return`Custom`;case`disabled`:return`Disabled`;case`unassigned`:return`No default`}}function kE(e){return e.target instanceof HTMLInputElement?e.target.value:``}async function AE(e){let[t,n]=await Promise.allSettled([e.loadConfig(),e.loadPlugins()]),r={error:``},i=[];return t.status===`fulfilled`?r.config=t.value:i.push(`config: ${ME(t.reason)}`),n.status===`fulfilled`?r.plugins=n.value:i.push(`PI WEBUI plugins: ${ME(n.reason)}`),i.length>0&&(r.error=`Failed to load settings: ${i.join(`; `)}`),r}async function jE(e,t,n){if(YT(n))return{error:n.message??`Pi package management is not available on ${KT(e)}.`,skipped:!0};try{return{packagesResponse:await t(e.id),error:``}}catch(t){return{error:`Failed to load Pi packages from ${KT(e)}: ${lE(ME(t),e)}`}}}function ME(e){return e instanceof Error?e.message:String(e)}function NE(e,t){return{...e,config:PE(e.config,t.config),effectiveConfig:PE(e.effectiveConfig,t.effectiveConfig)}}function PE(e,t){return{...e,...t.pathAccess===void 0?{}:{pathAccess:t.pathAccess},...t.uploads===void 0?{}:{uploads:t.uploads},...t.maxUploadBytes===void 0?{}:{maxUploadBytes:t.maxUploadBytes}}}function FE(e){return e===void 0?{id:`local`,name:`local`,kind:`local`}:{id:e.id,name:e.name,kind:e.kind}}function IE(e){return e.kind===`local`?`${e.name} (local gateway)`:`${e.name} (remote machine)`}function LE(e,t){return e.kind===`local`?{state:`supported`}:t?.ok===!0?Gt(t,T.selectedMachineSettings)?{state:`supported`}:{state:`unsupported`,message:HE(e)}:{state:`unknown`}}function RE(e,t){return e.kind===`local`?{state:`supported`}:t?.ok===!0?Gt(t,T.agentProfileConfig)?{state:`supported`}:{state:`unsupported`,message:`Pi-compatible agent profile settings are not available on ${e.name}. Update and restart PI WEBUI on that machine, then try again.`}:{state:`unknown`,message:`Pi-compatible agent profile support could not be verified on ${e.name}. Reload machine status before changing the profile.`}}function zE(e){return`${e.state}:${e.message??``}`}function BE(e){return e?.state===`unsupported`}function VE(e){return e?.state===`supported`}function HE(e){return`Selected-machine settings are not available on ${e.name}. Update and restart PI WEBUI on that machine, then try again.`}function UE(e,t){let n=e.trim();return t.kind===`remote`?WE(n)?HE(t):n===`Remote machine timeout`?`Timed out while contacting ${t.name} for selected-machine settings. The operation may still be running remotely; reload before retrying.`:n===`Remote machine unavailable`?`Could not reach ${t.name} for selected-machine settings. Check the machine connection and try again.`:n:n}function WE(e){return e===`Not Found`||/route\s+(GET|PUT):?\/api\/(config|plugins)\b.*not found/iu.test(e)||/cannot\s+(GET|PUT)\s+.*\/api\/(config|plugins)\b/iu.test(e)}function GE(e,t,n){let r=e.plugins??{},i=r[t]??{};return{plugins:{...r,[t]:{...i,enabled:n}}}}function KE(e,t){return{...e,config:qE(e.config,t.config),effectiveConfig:qE(e.effectiveConfig,t.effectiveConfig)}}function qE(e,t){return t.plugins===void 0?e:{...e,plugins:t.plugins}}var X=class extends y{constructor(...e){super(...e),this.section=`general`,this.actions=[],this.loading=!0,this.accessLoading=!0,this.sessiondLoading=!0,this.pluginLoading=!0,this.packageLoading=!0,this.saving=!1,this.error=``,this.accessError=``,this.sessiondError=``,this.pluginError=``,this.packageError=``,this.savedMessage=``,this.packageMessage=``,this.loadRequestSeq=0,this.accessLoadRequestSeq=0,this.sessiondLoadRequestSeq=0,this.pluginLoadRequestSeq=0,this.packageLoadRequestSeq=0,this.packageMutationSeq=0}connectedCallback(){super.connectedCallback(),this.loadConfig(),this.loadAccessConfigForTarget(),this.reloadSessiondState(),this.loadPluginsForTarget(),this.loadPackagesForTarget()}disconnectedCallback(){this.savedMessageTimer!==void 0&&window.clearTimeout(this.savedMessageTimer),this.savedMessageTimer=void 0,super.disconnectedCallback()}updated(e){let t=this.settingsTarget();if(e.has(`machine`)&&FE(e.get(`machine`)).id!==t.id){this.resetAccessStateForTargetChange(),this.isConnected&&this.loadAccessConfigForTarget(t),this.resetSessiondStateForTargetChange(),this.isConnected&&this.loadSessiondConfigForTarget(t),this.resetPluginStateForTargetChange(),this.isConnected&&this.loadPluginsForTarget(t),this.resetPackageStateForTargetChange(),this.isConnected&&this.loadPackagesForTarget(t);return}e.has(`machineRuntime`)&&(this.selectedMachineSettingsSupportNeedsReload(e.get(`machineRuntime`),t)&&(this.resetAccessStateForTargetChange(),this.isConnected&&this.loadAccessConfigForTarget(t),this.resetSessiondStateForTargetChange(),this.isConnected&&this.loadSessiondConfigForTarget(t),this.resetPluginStateForTargetChange(),this.isConnected&&this.loadPluginsForTarget(t)),this.packageManagementSupportNeedsReload(e.get(`machineRuntime`),t)&&(this.resetPackageStateForTargetChange(),this.isConnected&&this.loadPackagesForTarget(t)))}render(){return g`
|
|
4613
4737
|
<div class="backdrop" @mousedown=${()=>this.onClose?.()}>
|
|
4614
4738
|
<section class="settings-shell" role="dialog" aria-modal="true" aria-label="PI WEBUI settings" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
4615
4739
|
<header class="settings-header">
|
|
@@ -4640,7 +4764,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4640
4764
|
.saving=${this.saving}
|
|
4641
4765
|
.error=${this.sessiondError}
|
|
4642
4766
|
.savedMessage=${this.savedMessage}
|
|
4643
|
-
.targetLabel=${
|
|
4767
|
+
.targetLabel=${IE(this.settingsTarget())}
|
|
4644
4768
|
.activeAgentProfile=${this.machineRuntime?.components?.sessiond.activeAgentProfile}
|
|
4645
4769
|
.agentProfileSupport=${this.agentProfileSettingsSupport()}
|
|
4646
4770
|
.onReload=${()=>this.reloadSessiondState()}
|
|
@@ -4679,7 +4803,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4679
4803
|
.saving=${this.saving}
|
|
4680
4804
|
.error=${this.pluginError}
|
|
4681
4805
|
.savedMessage=${this.savedMessage}
|
|
4682
|
-
.targetLabel=${
|
|
4806
|
+
.targetLabel=${IE(this.settingsTarget())}
|
|
4683
4807
|
.onReload=${()=>this.loadPluginsForTarget()}
|
|
4684
4808
|
.onTogglePlugin=${(e,t)=>this.togglePlugin(e,t)}
|
|
4685
4809
|
></settings-plugins-panel>
|
|
@@ -4693,7 +4817,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4693
4817
|
.error=${this.error}
|
|
4694
4818
|
.machineError=${this.accessError}
|
|
4695
4819
|
.savedMessage=${this.savedMessage}
|
|
4696
|
-
.targetLabel=${
|
|
4820
|
+
.targetLabel=${IE(this.settingsTarget())}
|
|
4697
4821
|
.onReload=${()=>this.loadConfig()}
|
|
4698
4822
|
.onReloadMachine=${()=>this.loadAccessConfigForTarget()}
|
|
4699
4823
|
.onSave=${e=>this.saveConfig(e)}
|
|
@@ -4704,7 +4828,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4704
4828
|
<strong>${t}</strong>
|
|
4705
4829
|
<small>${n}</small>
|
|
4706
4830
|
</button>
|
|
4707
|
-
`}navigate(e){this.onNavigate?.(e)}async loadConfig(){let e=++this.loadRequestSeq;this.loading=!0,this.error=``;try{let t=await TE({loadConfig:()=>Ua.config(),loadPlugins:()=>Wa.plugins()});if(!this.isCurrentLoad(e))return;t.config!==void 0&&(this.configResponse=t.config),t.plugins!==void 0&&(this.pluginsResponse=t.plugins),this.error=t.error}finally{this.isCurrentLoad(e)&&(this.loading=!1)}}async loadAccessConfigForTarget(e=this.settingsTarget()){let t=++this.accessLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(FE(n)){this.accessConfigResponse=void 0,this.accessLoading=!1,this.accessError=n.message??`Selected-machine settings are not available on ${jE(e)}.`;return}this.accessLoading=!0,this.accessError=``;try{let n=await Ua.config(e.id);if(!this.isCurrentAccessLoad(t,e))return;this.accessConfigResponse=n}catch(n){this.isCurrentAccessLoad(t,e)&&(this.accessError=`Failed to load file access/upload config from ${jE(e)}: ${RE(UE(n),e)}`)}finally{this.isCurrentAccessLoad(t,e)&&(this.accessLoading=!1)}}async reloadSessiondState(e=this.settingsTarget()){await Promise.all([this.loadSessiondConfigForTarget(e),this.onRefreshMachineRuntime?.(e.id)])}async loadSessiondConfigForTarget(e=this.settingsTarget()){let t=++this.sessiondLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(FE(n)){this.sessiondConfigResponse=void 0,this.sessiondLoading=!1,this.sessiondError=n.message??`Selected-machine settings are not available on ${jE(e)}.`;return}this.sessiondLoading=!0,this.sessiondError=``;try{let n=await Ua.config(e.id);if(!this.isCurrentSessiondLoad(t,e))return;this.sessiondConfigResponse=n}catch(n){this.isCurrentSessiondLoad(t,e)&&(this.sessiondError=`Failed to load session-daemon config from ${jE(e)}: ${RE(UE(n),e)}`)}finally{this.isCurrentSessiondLoad(t,e)&&(this.sessiondLoading=!1)}}async loadPluginsForTarget(e=this.settingsTarget()){let t=++this.pluginLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(FE(n)){this.selectedPluginConfigResponse=void 0,this.selectedPluginsResponse=void 0,this.pluginLoading=!1,this.pluginError=n.message??`Selected-machine settings are not available on ${jE(e)}.`;return}this.pluginLoading=!0,this.pluginError=``;try{let[n,r]=await Promise.allSettled([Ua.config(e.id),Wa.plugins(e.id)]);if(!this.isCurrentPluginLoad(t,e))return;let i=[];n.status===`fulfilled`?this.selectedPluginConfigResponse=n.value:i.push(`config: ${RE(UE(n.reason),e)}`),r.status===`fulfilled`?this.selectedPluginsResponse=r.value:i.push(`PI WEBUI plugins: ${RE(UE(r.reason),e)}`),this.pluginError=i.length===0?``:`Failed to load PI WEBUI plugin settings from ${jE(e)}: ${i.join(`; `)}`}finally{this.isCurrentPluginLoad(t,e)&&(this.pluginLoading=!1)}}async loadPackagesForTarget(e=this.packageTarget()){let t=++this.packageLoadRequestSeq;this.packageLoading=!0,this.packageError=``,this.packageMessage=``;try{let n=await EE(e,e=>Za.packages(e),this.packageManagementSupport(e));if(!this.isCurrentPackageLoad(t,e))return;this.packagesResponse=n.packagesResponse,this.packageError=n.error}finally{this.isCurrentPackageLoad(t,e)&&(this.packageLoading=!1)}}async togglePlugin(e,t){if(this.saving)return;let n=this.settingsTarget(),r=this.selectedMachineSettingsSupport(n);if(FE(r)){this.pluginError=r.message??`Selected-machine settings are not available on ${jE(n)}.`;return}if(this.selectedPluginConfigResponse===void 0){this.pluginError=`Plugin config is not loaded for ${jE(n)}. Reload before changing plugin enablement.`;return}let i=BE(this.selectedPluginConfigResponse.config,e,t);this.saving=!0,this.pluginError=``,this.savedMessage=``;try{let e=await Ua.saveConfig(i,n.id);if(!this.isCurrentSettingsTarget(n))return;this.selectedPluginConfigResponse=e,n.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=VE(this.configResponse,e),this.onConfigSaved?.(this.configResponse.effectiveConfig));let t=await this.refreshPluginsForTarget(n);if(!this.isCurrentSettingsTarget(n))return;t!==void 0&&(this.pluginError=t),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(n)&&(this.pluginError=`Failed to save PI WEBUI plugin config on ${jE(n)}: ${RE(UE(e),n)}`)}finally{this.saving=!1}}async saveConfig(e){if(!this.saving){this.saving=!0,this.error=``,this.savedMessage=``;try{let t=await Ua.saveConfig(e);this.configResponse=t,this.onConfigSaved?.(t.effectiveConfig),this.showSavedMessage()}catch(e){this.error=`Failed to save config: ${UE(e)}`}finally{this.saving=!1}}}async saveMachineAccessConfig(e){if(this.saving)return;let t=this.settingsTarget(),n=this.selectedMachineSettingsSupport(t);if(FE(n)){this.accessError=n.message??`Selected-machine settings are not available on ${jE(t)}.`;return}this.saving=!0,this.accessError=``,this.savedMessage=``;try{let n=await Ua.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.accessConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=OE(this.configResponse,n),this.onConfigSaved?.(this.configResponse.effectiveConfig)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.accessError=`Failed to save file access/upload config on ${jE(t)}: ${RE(UE(e),t)}`)}finally{this.saving=!1}}async saveSessiondConfig(e){if(this.saving)return;let t=this.settingsTarget(),n=this.selectedMachineSettingsSupport(t);if(FE(n)){this.sessiondError=n.message??`Selected-machine settings are not available on ${jE(t)}.`;return}if(e.agent!==void 0){let e=this.agentProfileSettingsSupport(t);if(!IE(e)){this.sessiondError=e.message??`Pi-compatible agent profile settings are not available on ${jE(t)}.`;return}}this.saving=!0,this.sessiondError=``,this.savedMessage=``;try{let n=await Ua.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.sessiondConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=MT(this.configResponse,n)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.sessiondError=`Failed to save session-daemon config on ${jE(t)}: ${RE(UE(e),t)}`)}finally{this.saving=!1}}async installPiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation({kind:`install`,source:e},`install Pi package`,t,()=>Za.install(e,t.id))}async removePiPackage(e,t){let n=this.packageTarget();await this.runPiPackageMutation({kind:`remove`,source:e},`remove Pi package`,n,()=>Za.remove(e,t,n.id))}async updatePiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation(e===void 0?{kind:`update-all`}:{kind:`update`,source:e},`update Pi packages`,t,()=>Za.update(e,t.id))}async runPiPackageMutation(e,t,n,r){let i=this.packageManagementSupport(n);if(WT(i))throw this.packageError=i.message??`Pi package management is not available on ${VT(n)}.`,Error(this.packageError);if(this.saving)throw Error(`A settings operation is already running.`);let a=++this.packageMutationSeq;this.packageLoadRequestSeq+=1,this.packageLoading=!1,this.saving=!0,this.packageOperation=e,this.packageError=``,this.packageMessage=``;try{let e=await r();if(!this.isCurrentPackageMutation(a,n))return;this.packagesResponse={packages:e.packages};let t=KT(n)?await this.refreshGatewayPlugins():void 0;if(!this.isCurrentPackageMutation(a,n))return;t!==void 0&&(this.packageError=t),this.packageMessage=rE(e.action,n)}catch(e){throw this.isCurrentPackageMutation(a,n)&&(this.packageError=`Failed to ${t} on ${VT(n)}: ${iE(UE(e),n)}`),e}finally{this.packageMutationSeq===a&&(this.packageOperation=void 0,this.saving=!1)}}async refreshGatewayPlugins(){try{this.pluginsResponse=await Wa.plugins();return}catch(e){return`Failed to refresh gateway PI WEBUI plugins: ${UE(e)}`}}async refreshPluginsForTarget(e){try{let t=await Wa.plugins(e.id);this.isCurrentSettingsTarget(e)&&(this.selectedPluginsResponse=t);return}catch(t){return`Config saved, but failed to refresh PI WEBUI plugins from ${jE(e)}: ${RE(UE(t),e)}`}}settingsTarget(){return AE(this.machine)}packageTarget(){return this.settingsTarget()}selectedMachineSettingsSupport(e=this.settingsTarget()){return ME(e,this.machineRuntime)}agentProfileSettingsSupport(e=this.settingsTarget()){return NE(e,this.machineRuntime)}selectedMachineSettingsSupportNeedsReload(e,t){let n=ME(t,e),r=this.selectedMachineSettingsSupport(t);return PE(n)!==PE(r)}packageManagementSupport(e=this.packageTarget()){return HT(e,this.machineRuntime)}packageManagementSupportNeedsReload(e,t){let n=HT(t,e),r=this.packageManagementSupport(t);return UT(n)===UT(r)?!1:n.state===`unsupported`||r.state===`unsupported`}isCurrentLoad(e){return e===this.loadRequestSeq}isCurrentAccessLoad(e,t){return e===this.accessLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentSessiondLoad(e,t){return e===this.sessiondLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPluginLoad(e,t){return e===this.pluginLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPackageLoad(e,t){return e===this.packageLoadRequestSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageMutation(e,t){return e===this.packageMutationSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageTarget(e){return this.packageTarget().id===e.id}isCurrentSettingsTarget(e){return this.settingsTarget().id===e.id}resetAccessStateForTargetChange(){this.accessLoadRequestSeq+=1,this.accessLoading=!1,this.accessError=``,this.accessConfigResponse=void 0,this.savedMessage=``}resetSessiondStateForTargetChange(){this.sessiondLoadRequestSeq+=1,this.sessiondLoading=!1,this.sessiondError=``,this.sessiondConfigResponse=void 0,this.savedMessage=``}resetPluginStateForTargetChange(){this.pluginLoadRequestSeq+=1,this.pluginLoading=!1,this.pluginError=``,this.selectedPluginConfigResponse=void 0,this.selectedPluginsResponse=void 0,this.savedMessage=``}resetPackageStateForTargetChange(){let e=this.packageOperation!==void 0;this.packageLoadRequestSeq+=1,this.packageMutationSeq+=1,this.packageLoading=!1,this.packageOperation=void 0,this.packageMessage=``,this.packageError=``,this.packagesResponse=void 0,e&&(this.saving=!1)}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?.())}static{this.styles=h`
|
|
4831
|
+
`}navigate(e){this.onNavigate?.(e)}async loadConfig(){let e=++this.loadRequestSeq;this.loading=!0,this.error=``;try{let t=await AE({loadConfig:()=>Ua.config(),loadPlugins:()=>Wa.plugins()});if(!this.isCurrentLoad(e))return;t.config!==void 0&&(this.configResponse=t.config),t.plugins!==void 0&&(this.pluginsResponse=t.plugins),this.error=t.error}finally{this.isCurrentLoad(e)&&(this.loading=!1)}}async loadAccessConfigForTarget(e=this.settingsTarget()){let t=++this.accessLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(BE(n)){this.accessConfigResponse=void 0,this.accessLoading=!1,this.accessError=n.message??`Selected-machine settings are not available on ${IE(e)}.`;return}this.accessLoading=!0,this.accessError=``;try{let n=await Ua.config(e.id);if(!this.isCurrentAccessLoad(t,e))return;this.accessConfigResponse=n}catch(n){this.isCurrentAccessLoad(t,e)&&(this.accessError=`Failed to load file access/upload config from ${IE(e)}: ${UE(JE(n),e)}`)}finally{this.isCurrentAccessLoad(t,e)&&(this.accessLoading=!1)}}async reloadSessiondState(e=this.settingsTarget()){await Promise.all([this.loadSessiondConfigForTarget(e),this.onRefreshMachineRuntime?.(e.id)])}async loadSessiondConfigForTarget(e=this.settingsTarget()){let t=++this.sessiondLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(BE(n)){this.sessiondConfigResponse=void 0,this.sessiondLoading=!1,this.sessiondError=n.message??`Selected-machine settings are not available on ${IE(e)}.`;return}this.sessiondLoading=!0,this.sessiondError=``;try{let n=await Ua.config(e.id);if(!this.isCurrentSessiondLoad(t,e))return;this.sessiondConfigResponse=n}catch(n){this.isCurrentSessiondLoad(t,e)&&(this.sessiondError=`Failed to load session-daemon config from ${IE(e)}: ${UE(JE(n),e)}`)}finally{this.isCurrentSessiondLoad(t,e)&&(this.sessiondLoading=!1)}}async loadPluginsForTarget(e=this.settingsTarget()){let t=++this.pluginLoadRequestSeq,n=this.selectedMachineSettingsSupport(e);if(BE(n)){this.selectedPluginConfigResponse=void 0,this.selectedPluginsResponse=void 0,this.pluginLoading=!1,this.pluginError=n.message??`Selected-machine settings are not available on ${IE(e)}.`;return}this.pluginLoading=!0,this.pluginError=``;try{let[n,r]=await Promise.allSettled([Ua.config(e.id),Wa.plugins(e.id)]);if(!this.isCurrentPluginLoad(t,e))return;let i=[];n.status===`fulfilled`?this.selectedPluginConfigResponse=n.value:i.push(`config: ${UE(JE(n.reason),e)}`),r.status===`fulfilled`?this.selectedPluginsResponse=r.value:i.push(`PI WEBUI plugins: ${UE(JE(r.reason),e)}`),this.pluginError=i.length===0?``:`Failed to load PI WEBUI plugin settings from ${IE(e)}: ${i.join(`; `)}`}finally{this.isCurrentPluginLoad(t,e)&&(this.pluginLoading=!1)}}async loadPackagesForTarget(e=this.packageTarget()){let t=++this.packageLoadRequestSeq;this.packageLoading=!0,this.packageError=``,this.packageMessage=``;try{let n=await jE(e,e=>Za.packages(e),this.packageManagementSupport(e));if(!this.isCurrentPackageLoad(t,e))return;this.packagesResponse=n.packagesResponse,this.packageError=n.error}finally{this.isCurrentPackageLoad(t,e)&&(this.packageLoading=!1)}}async togglePlugin(e,t){if(this.saving)return;let n=this.settingsTarget(),r=this.selectedMachineSettingsSupport(n);if(BE(r)){this.pluginError=r.message??`Selected-machine settings are not available on ${IE(n)}.`;return}if(this.selectedPluginConfigResponse===void 0){this.pluginError=`Plugin config is not loaded for ${IE(n)}. Reload before changing plugin enablement.`;return}let i=GE(this.selectedPluginConfigResponse.config,e,t);this.saving=!0,this.pluginError=``,this.savedMessage=``;try{let e=await Ua.saveConfig(i,n.id);if(!this.isCurrentSettingsTarget(n))return;this.selectedPluginConfigResponse=e,n.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=KE(this.configResponse,e),this.onConfigSaved?.(this.configResponse.effectiveConfig));let t=await this.refreshPluginsForTarget(n);if(!this.isCurrentSettingsTarget(n))return;t!==void 0&&(this.pluginError=t),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(n)&&(this.pluginError=`Failed to save PI WEBUI plugin config on ${IE(n)}: ${UE(JE(e),n)}`)}finally{this.saving=!1}}async saveConfig(e){if(!this.saving){this.saving=!0,this.error=``,this.savedMessage=``;try{let t=await Ua.saveConfig(e);this.configResponse=t,this.onConfigSaved?.(t.effectiveConfig),this.showSavedMessage()}catch(e){this.error=`Failed to save config: ${JE(e)}`}finally{this.saving=!1}}}async saveMachineAccessConfig(e){if(this.saving)return;let t=this.settingsTarget(),n=this.selectedMachineSettingsSupport(t);if(BE(n)){this.accessError=n.message??`Selected-machine settings are not available on ${IE(t)}.`;return}this.saving=!0,this.accessError=``,this.savedMessage=``;try{let n=await Ua.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.accessConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=NE(this.configResponse,n),this.onConfigSaved?.(this.configResponse.effectiveConfig)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.accessError=`Failed to save file access/upload config on ${IE(t)}: ${UE(JE(e),t)}`)}finally{this.saving=!1}}async saveSessiondConfig(e){if(this.saving)return;let t=this.settingsTarget(),n=this.selectedMachineSettingsSupport(t);if(BE(n)){this.sessiondError=n.message??`Selected-machine settings are not available on ${IE(t)}.`;return}if(e.agent!==void 0){let e=this.agentProfileSettingsSupport(t);if(!VE(e)){this.sessiondError=e.message??`Pi-compatible agent profile settings are not available on ${IE(t)}.`;return}}this.saving=!0,this.sessiondError=``,this.savedMessage=``;try{let n=await Ua.saveConfig(e,t.id);if(!this.isCurrentSettingsTarget(t))return;this.sessiondConfigResponse=n,t.kind===`local`&&this.configResponse!==void 0&&(this.configResponse=LT(this.configResponse,n)),this.showSavedMessage()}catch(e){this.isCurrentSettingsTarget(t)&&(this.sessiondError=`Failed to save session-daemon config on ${IE(t)}: ${UE(JE(e),t)}`)}finally{this.saving=!1}}async installPiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation({kind:`install`,source:e},`install Pi package`,t,()=>Za.install(e,t.id))}async removePiPackage(e,t){let n=this.packageTarget();await this.runPiPackageMutation({kind:`remove`,source:e},`remove Pi package`,n,()=>Za.remove(e,t,n.id))}async updatePiPackage(e){let t=this.packageTarget();await this.runPiPackageMutation(e===void 0?{kind:`update-all`}:{kind:`update`,source:e},`update Pi packages`,t,()=>Za.update(e,t.id))}async runPiPackageMutation(e,t,n,r){let i=this.packageManagementSupport(n);if(YT(i))throw this.packageError=i.message??`Pi package management is not available on ${KT(n)}.`,Error(this.packageError);if(this.saving)throw Error(`A settings operation is already running.`);let a=++this.packageMutationSeq;this.packageLoadRequestSeq+=1,this.packageLoading=!1,this.saving=!0,this.packageOperation=e,this.packageError=``,this.packageMessage=``;try{let e=await r();if(!this.isCurrentPackageMutation(a,n))return;this.packagesResponse={packages:e.packages};let t=ZT(n)?await this.refreshGatewayPlugins():void 0;if(!this.isCurrentPackageMutation(a,n))return;t!==void 0&&(this.packageError=t),this.packageMessage=cE(e.action,n)}catch(e){throw this.isCurrentPackageMutation(a,n)&&(this.packageError=`Failed to ${t} on ${KT(n)}: ${lE(JE(e),n)}`),e}finally{this.packageMutationSeq===a&&(this.packageOperation=void 0,this.saving=!1)}}async refreshGatewayPlugins(){try{this.pluginsResponse=await Wa.plugins();return}catch(e){return`Failed to refresh gateway PI WEBUI plugins: ${JE(e)}`}}async refreshPluginsForTarget(e){try{let t=await Wa.plugins(e.id);this.isCurrentSettingsTarget(e)&&(this.selectedPluginsResponse=t);return}catch(t){return`Config saved, but failed to refresh PI WEBUI plugins from ${IE(e)}: ${UE(JE(t),e)}`}}settingsTarget(){return FE(this.machine)}packageTarget(){return this.settingsTarget()}selectedMachineSettingsSupport(e=this.settingsTarget()){return LE(e,this.machineRuntime)}agentProfileSettingsSupport(e=this.settingsTarget()){return RE(e,this.machineRuntime)}selectedMachineSettingsSupportNeedsReload(e,t){let n=LE(t,e),r=this.selectedMachineSettingsSupport(t);return zE(n)!==zE(r)}packageManagementSupport(e=this.packageTarget()){return qT(e,this.machineRuntime)}packageManagementSupportNeedsReload(e,t){let n=qT(t,e),r=this.packageManagementSupport(t);return JT(n)===JT(r)?!1:n.state===`unsupported`||r.state===`unsupported`}isCurrentLoad(e){return e===this.loadRequestSeq}isCurrentAccessLoad(e,t){return e===this.accessLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentSessiondLoad(e,t){return e===this.sessiondLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPluginLoad(e,t){return e===this.pluginLoadRequestSeq&&this.isCurrentSettingsTarget(t)}isCurrentPackageLoad(e,t){return e===this.packageLoadRequestSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageMutation(e,t){return e===this.packageMutationSeq&&this.isCurrentPackageTarget(t)}isCurrentPackageTarget(e){return this.packageTarget().id===e.id}isCurrentSettingsTarget(e){return this.settingsTarget().id===e.id}resetAccessStateForTargetChange(){this.accessLoadRequestSeq+=1,this.accessLoading=!1,this.accessError=``,this.accessConfigResponse=void 0,this.savedMessage=``}resetSessiondStateForTargetChange(){this.sessiondLoadRequestSeq+=1,this.sessiondLoading=!1,this.sessiondError=``,this.sessiondConfigResponse=void 0,this.savedMessage=``}resetPluginStateForTargetChange(){this.pluginLoadRequestSeq+=1,this.pluginLoading=!1,this.pluginError=``,this.selectedPluginConfigResponse=void 0,this.selectedPluginsResponse=void 0,this.savedMessage=``}resetPackageStateForTargetChange(){let e=this.packageOperation!==void 0;this.packageLoadRequestSeq+=1,this.packageMutationSeq+=1,this.packageLoading=!1,this.packageOperation=void 0,this.packageMessage=``,this.packageError=``,this.packagesResponse=void 0,e&&(this.saving=!1)}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?.())}static{this.styles=h`
|
|
4708
4832
|
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
4709
4833
|
.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; }
|
|
4710
4834
|
.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; }
|
|
@@ -4731,7 +4855,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4731
4855
|
.settings-nav button { flex: 0 0 auto; width: auto; min-width: 128px; margin: 0; }
|
|
4732
4856
|
.settings-content { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
|
|
4733
4857
|
}
|
|
4734
|
-
`}};B([x({attribute:!1})],X.prototype,`section`,void 0),B([x({attribute:!1})],X.prototype,`actions`,void 0),B([x({attribute:!1})],X.prototype,`machine`,void 0),B([x({attribute:!1})],X.prototype,`machineRuntime`,void 0),B([x({attribute:!1})],X.prototype,`onNavigate`,void 0),B([x({attribute:!1})],X.prototype,`onClose`,void 0),B([x({attribute:!1})],X.prototype,`onConfigSaved`,void 0),B([x({attribute:!1})],X.prototype,`onRefreshMachineRuntime`,void 0),B([S()],X.prototype,`configResponse`,void 0),B([S()],X.prototype,`accessConfigResponse`,void 0),B([S()],X.prototype,`sessiondConfigResponse`,void 0),B([S()],X.prototype,`pluginsResponse`,void 0),B([S()],X.prototype,`selectedPluginConfigResponse`,void 0),B([S()],X.prototype,`selectedPluginsResponse`,void 0),B([S()],X.prototype,`packagesResponse`,void 0),B([S()],X.prototype,`loading`,void 0),B([S()],X.prototype,`accessLoading`,void 0),B([S()],X.prototype,`sessiondLoading`,void 0),B([S()],X.prototype,`pluginLoading`,void 0),B([S()],X.prototype,`packageLoading`,void 0),B([S()],X.prototype,`saving`,void 0),B([S()],X.prototype,`packageOperation`,void 0),B([S()],X.prototype,`error`,void 0),B([S()],X.prototype,`accessError`,void 0),B([S()],X.prototype,`sessiondError`,void 0),B([S()],X.prototype,`pluginError`,void 0),B([S()],X.prototype,`packageError`,void 0),B([S()],X.prototype,`savedMessage`,void 0),B([S()],X.prototype,`packageMessage`,void 0),X=B([b(`settings-dialog`)],X);function
|
|
4858
|
+
`}};B([x({attribute:!1})],X.prototype,`section`,void 0),B([x({attribute:!1})],X.prototype,`actions`,void 0),B([x({attribute:!1})],X.prototype,`machine`,void 0),B([x({attribute:!1})],X.prototype,`machineRuntime`,void 0),B([x({attribute:!1})],X.prototype,`onNavigate`,void 0),B([x({attribute:!1})],X.prototype,`onClose`,void 0),B([x({attribute:!1})],X.prototype,`onConfigSaved`,void 0),B([x({attribute:!1})],X.prototype,`onRefreshMachineRuntime`,void 0),B([S()],X.prototype,`configResponse`,void 0),B([S()],X.prototype,`accessConfigResponse`,void 0),B([S()],X.prototype,`sessiondConfigResponse`,void 0),B([S()],X.prototype,`pluginsResponse`,void 0),B([S()],X.prototype,`selectedPluginConfigResponse`,void 0),B([S()],X.prototype,`selectedPluginsResponse`,void 0),B([S()],X.prototype,`packagesResponse`,void 0),B([S()],X.prototype,`loading`,void 0),B([S()],X.prototype,`accessLoading`,void 0),B([S()],X.prototype,`sessiondLoading`,void 0),B([S()],X.prototype,`pluginLoading`,void 0),B([S()],X.prototype,`packageLoading`,void 0),B([S()],X.prototype,`saving`,void 0),B([S()],X.prototype,`packageOperation`,void 0),B([S()],X.prototype,`error`,void 0),B([S()],X.prototype,`accessError`,void 0),B([S()],X.prototype,`sessiondError`,void 0),B([S()],X.prototype,`pluginError`,void 0),B([S()],X.prototype,`packageError`,void 0),B([S()],X.prototype,`savedMessage`,void 0),B([S()],X.prototype,`packageMessage`,void 0),X=B([b(`settings-dialog`)],X);function JE(e){return e instanceof Error?e.message:String(e)}var YE=class extends y{constructor(...e){super(...e),this.sessionsApi=io,this.loading=!0,this.error=``,this.loadRequestSequence=0}connectedCallback(){super.connectedCallback(),this.loadSystemPrompt()}updated(e){let t=e.has(`session`)&&ZE(e.get(`session`))!==ZE(this.session),n=e.has(`machine`)&&XE(e.get(`machine`))!==XE(this.machine);(t||n)&&this.isConnected&&this.loadSystemPrompt()}render(){return g`
|
|
4735
4859
|
<div class="backdrop" @mousedown=${e=>{e.target===e.currentTarget&&this.close()}}>
|
|
4736
4860
|
<section class="dialog" role="dialog" aria-modal="true" aria-labelledby="system-prompt-dialog-title" @mousedown=${e=>{e.stopPropagation()}} @keydown=${e=>{this.handleKeyDown(e)}}>
|
|
4737
4861
|
<header>
|
|
@@ -4740,7 +4864,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4740
4864
|
<h1 id="system-prompt-dialog-title">System prompt</h1>
|
|
4741
4865
|
</div>
|
|
4742
4866
|
<button class="icon-button" type="button" title="Close system prompt" aria-label="Close system prompt" @click=${()=>{this.close()}}>
|
|
4743
|
-
${
|
|
4867
|
+
${tD()}
|
|
4744
4868
|
</button>
|
|
4745
4869
|
</header>
|
|
4746
4870
|
<div class="prompt-body" aria-live="polite">
|
|
@@ -4751,7 +4875,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4751
4875
|
</footer>
|
|
4752
4876
|
</section>
|
|
4753
4877
|
</div>
|
|
4754
|
-
`}renderPrompt(){return this.loading?g`<p class="prompt-state">Loading system prompt…</p>`:this.error===``?this.systemPrompt===void 0?g`<p class="prompt-state">Send a message to load the system prompt</p>`:this.systemPrompt===``?g`<p class="prompt-state">System prompt is empty (tools are disabled)</p>`:g`<pre class="system-prompt">${this.systemPrompt}</pre>`:g`<p class="prompt-state error">${this.error}</p>`}async loadSystemPrompt(){let e=this.session,t=e===void 0?void 0
|
|
4878
|
+
`}renderPrompt(){return this.loading?g`<p class="prompt-state">Loading system prompt…</p>`:this.error===``?this.systemPrompt===void 0?g`<p class="prompt-state">Send a message to load the system prompt</p>`:this.systemPrompt===``?g`<p class="prompt-state">System prompt is empty (tools are disabled)</p>`:g`<pre class="system-prompt">${this.systemPrompt}</pre>`:g`<p class="prompt-state error">${this.error}</p>`}async loadSystemPrompt(){let e=this.session,t=e===void 0?void 0:$E(XE(this.machine),e),n=++this.loadRequestSequence;if(this.loading=!0,this.error=``,this.systemPrompt=void 0,e===void 0||t===void 0){this.loading=!1;return}try{let r=await this.sessionsApi.systemPrompt(e,XE(this.machine));if(!this.isCurrentLoad(n,t))return;this.systemPrompt=r.systemPrompt}catch(e){if(!this.isCurrentLoad(n,t))return;this.error=`Failed to load system prompt: ${eD(e)}`}finally{this.isCurrentLoad(n,t)&&(this.loading=!1)}}isCurrentLoad(e,t){let n=this.session;return e===this.loadRequestSequence&&n!==void 0&&$E(XE(this.machine),n)===t}handleKeyDown(e){e.key===`Escape`&&(e.preventDefault(),this.close())}close(){this.onClose?.()}static{this.styles=h`
|
|
4755
4879
|
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
4756
4880
|
* { box-sizing: border-box; }
|
|
4757
4881
|
.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; }
|
|
@@ -4777,11 +4901,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4777
4901
|
header, footer { padding: 12px; }
|
|
4778
4902
|
.system-prompt, .prompt-state { padding: 12px; }
|
|
4779
4903
|
}
|
|
4780
|
-
`}};B([x({attribute:!1})],
|
|
4904
|
+
`}};B([x({attribute:!1})],YE.prototype,`machine`,void 0),B([x({attribute:!1})],YE.prototype,`session`,void 0),B([x({attribute:!1})],YE.prototype,`sessionsApi`,void 0),B([x({attribute:!1})],YE.prototype,`onClose`,void 0),B([S()],YE.prototype,`systemPrompt`,void 0),B([S()],YE.prototype,`loading`,void 0),B([S()],YE.prototype,`error`,void 0),YE=B([b(`system-prompt-dialog`)],YE);function XE(e){return e?.id??`local`}function ZE(e){return e===void 0?void 0:QE(e)}function QE(e){return JSON.stringify([e.id,e.cwd])}function $E(e,t){return JSON.stringify([e,t.id,t.cwd])}function eD(e){return e instanceof Error?e.message:String(e)}function tD(){return _`
|
|
4781
4905
|
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
4782
4906
|
<path d="M6 6l12 12M18 6 6 18"></path>
|
|
4783
4907
|
</svg>
|
|
4784
|
-
`}var
|
|
4908
|
+
`}var nD=class extends y{constructor(...e){super(...e),this.tool=`core:workspace.files`,this.panels=[],this.hiddenTools=[],this.hideToolTabs=!1,this.onSelectTool=()=>void 0,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.`});let e=this.panelContext;if(e===void 0)return this.renderEmptyState({title:`Workspace tools unavailable`,body:`Try selecting the workspace again.`});let t=this.panels,n=t.filter(e=>!this.hiddenTools.includes(e.id)),r=t.find(e=>e.id===this.tool)??t[0];return g`
|
|
4785
4909
|
${this.hideToolTabs?null:g`
|
|
4786
4910
|
<header>
|
|
4787
4911
|
<div class=${this.workspaceHeaderFrameClass()}>
|
|
@@ -4811,10 +4935,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4811
4935
|
<h2>${e.title}</h2>
|
|
4812
4936
|
${e.body===void 0?null:g`<p>${e.body}</p>`}
|
|
4813
4937
|
</section>
|
|
4814
|
-
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${this.workspaceHeaderCanScrollLeft?` can-scroll-left`:``}${this.workspaceHeaderCanScrollRight?` can-scroll-right`:``}`}observeWorkspaceHeaderStrip(){let 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(){let e=this.workspaceHeaderStripElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),n=e!==void 0&&e.scrollLeft>1,r=e!==void 0&&t-e.scrollLeft>1;this.workspaceHeaderCanScrollLeft!==n&&(this.workspaceHeaderCanScrollLeft=n),this.workspaceHeaderCanScrollRight!==r&&(this.workspaceHeaderCanScrollRight=r)}workspaceHeaderStripElement(){let e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}static{this.styles=Kp}};B([x({attribute:!1})],
|
|
4815
|
-
`),lines:p,physicalLineCount:f.length,viewportLine:Math.min(d,Math.max(0,e.viewportY))}}function
|
|
4938
|
+
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${this.workspaceHeaderCanScrollLeft?` can-scroll-left`:``}${this.workspaceHeaderCanScrollRight?` can-scroll-right`:``}`}observeWorkspaceHeaderStrip(){let 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(){let e=this.workspaceHeaderStripElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),n=e!==void 0&&e.scrollLeft>1,r=e!==void 0&&t-e.scrollLeft>1;this.workspaceHeaderCanScrollLeft!==n&&(this.workspaceHeaderCanScrollLeft=n),this.workspaceHeaderCanScrollRight!==r&&(this.workspaceHeaderCanScrollRight=r)}workspaceHeaderStripElement(){let e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}static{this.styles=Kp}};B([x({attribute:!1})],nD.prototype,`workspace`,void 0),B([x({attribute:!1})],nD.prototype,`panelContext`,void 0),B([x({attribute:!1})],nD.prototype,`emptyState`,void 0),B([x()],nD.prototype,`tool`,void 0),B([x({attribute:!1})],nD.prototype,`panels`,void 0),B([x({attribute:!1})],nD.prototype,`hiddenTools`,void 0),B([x({type:Boolean})],nD.prototype,`hideToolTabs`,void 0),B([x({attribute:!1})],nD.prototype,`onSelectTool`,void 0),B([C(`.workspace-header-strip`)],nD.prototype,`workspaceHeaderStrip`,void 0),B([S()],nD.prototype,`workspaceHeaderCanScrollLeft`,void 0),B([S()],nD.prototype,`workspaceHeaderCanScrollRight`,void 0),nD=B([b(`workspace-panel`)],nD);var rD=`important`,iD=` !important`,aD=S_(class extends C_{constructor(e){if(super(e),e.type!==x_.ATTRIBUTE||e.name!==`style`||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return r==null?t:t+`${n=n.includes(`-`)?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,`-$&`).toLowerCase()}:${r};`},``)}update(e,[t]){let{style:n}=e.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let e of this.ft)t[e]??(this.ft.delete(e),e.includes(`-`)?n.removeProperty(e):n[e]=null);for(let e in t){let r=t[e];if(r!=null){this.ft.add(e);let t=typeof r==`string`&&r.endsWith(iD);e.includes(`-`)||t?n.setProperty(e,t?r.slice(0,-11):r,t?rD:``):n[e]=r}}return Qe}}),oD=`#ffffff`,sD=`#000000`,cD=[`#2e3436`,`#cc0000`,`#4e9a06`,`#c4a000`,`#3465a4`,`#75507b`,`#06989a`,`#d3d7cf`,`#555753`,`#ef2929`,`#8ae234`,`#fce94f`,`#729fcf`,`#ad7fa8`,`#34e2e2`,`#eeeeec`],lD=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`],uD={black:cD[0],red:cD[1],green:cD[2],yellow:cD[3],blue:cD[4],magenta:cD[5],cyan:cD[6],white:cD[7],brightBlack:cD[8],brightRed:cD[9],brightGreen:cD[10],brightYellow:cD[11],brightBlue:cD[12],brightMagenta:cD[13],brightCyan:cD[14],brightWhite:cD[15]};function dD(e,t,n={}){let r=Math.max(0,Math.floor(t));if(e.length<=0||r===0)return{text:``,lines:[],physicalLineCount:0,viewportLine:0};let i=yD(n.theme),a=n.theme?.foreground??oD,o=n.theme?.background??sD,s=[],c=e.getNullCell(),l=-1;for(let t=0;t<e.length;t+=1){let u=e.getLine(t);if(u===void 0){s.push({text:``,runs:[],wrapped:!1});continue}let d=fD(u,r,c,{palette:i,foreground:a,background:o,drawBoldTextInBrightColors:n.drawBoldTextInBrightColors!==!1});s.push(d),(d.text!==``||d.runs.some(e=>e.style.background!==o))&&(l=t)}let u=Math.min(e.length-1,Math.max(0,e.baseY+e.cursorY)),d=Math.max(l,u),f=s.slice(0,d+1),p=[];for(let e of f){let t=p.at(-1);if(e.wrapped&&t!==void 0){t.text+=e.text,gD(t.runs,e.runs);continue}p.push({text:e.text,runs:e.runs.map(e=>({text:e.text,style:e.style}))})}return{text:p.map(e=>e.text).join(`
|
|
4939
|
+
`),lines:p,physicalLineCount:f.length,viewportLine:Math.min(d,Math.max(0,e.viewportY))}}function fD(e,t,n,r){let i=[],a=Math.min(t,e.length);for(let t=0;t<a;t+=1){let a=e.getCell(t,n);if(a===void 0){i.push({text:` `,meaningful:!1,style:hD(r)});continue}let o=a.getWidth();if(o===0)continue;let s=a.getChars();i.push({text:s===``?` `.repeat(Math.max(1,o)):s,meaningful:s!==``||!a.isAttributeDefault(),style:pD(a,r)})}let o=i.length-1;for(;o>=0&&i[o]?.meaningful!==!0;)--o;let s=[],c=``;for(let e=0;e<=o;e+=1){let t=i[e];t!==void 0&&(c+=t.text,_D(s,{text:t.text,style:t.style}))}return{text:c,runs:s,wrapped:e.isWrapped}}function pD(e,t){let n=e.isInverse()!==0,r=mD(e,`foreground`,t),i=mD(e,`background`,t);if(n&&([r,i]=[i,r]),e.isBold()!==0&&t.drawBoldTextInBrightColors){let i=n?e.isBgPalette()?e.getBgColor():void 0:e.isFgPalette()?e.getFgColor():void 0;i!==void 0&&i>=0&&i<8&&(r=t.palette[i+8]??r)}return{foreground:r,background:i,bold:e.isBold()!==0,italic:e.isItalic()!==0,dim:e.isDim()!==0,underline:e.isUnderline()!==0,invisible:e.isInvisible()!==0,strikethrough:e.isStrikethrough()!==0,overline:e.isOverline()!==0}}function mD(e,t,n){let r=t===`foreground`?e.isFgRGB():e.isBgRGB(),i=t===`foreground`?e.isFgPalette():e.isBgPalette(),a=t===`foreground`?e.getFgColor():e.getBgColor();return r?bD(a):i?n.palette[a]??(t===`foreground`?n.foreground:n.background):t===`foreground`?n.foreground:n.background}function hD(e){return{foreground:e.foreground,background:e.background,bold:!1,italic:!1,dim:!1,underline:!1,invisible:!1,strikethrough:!1,overline:!1}}function gD(e,t){for(let n of t)_D(e,n)}function _D(e,t){if(t.text===``)return;let n=e.at(-1);if(n!==void 0&&vD(n.style,t.style)){n.text+=t.text;return}e.push({text:t.text,style:t.style})}function vD(e,t){return e.foreground===t.foreground&&e.background===t.background&&e.bold===t.bold&&e.italic===t.italic&&e.dim===t.dim&&e.underline===t.underline&&e.invisible===t.invisible&&e.strikethrough===t.strikethrough&&e.overline===t.overline}function yD(e){let t=[...cD];for(let n=0;n<lD.length;n+=1){let r=lD[n];if(r===void 0)continue;let i=e?.[r];typeof i==`string`&&(t[n]=i)}let n=[0,95,135,175,215,255];for(let e=0;e<216;e+=1){let r=n[Math.floor(e/36)%6]??0,i=n[Math.floor(e/6)%6]??0,a=n[e%6]??0;t.push(xD(r,i,a))}for(let e=0;e<24;e+=1){let n=8+e*10;t.push(xD(n,n,n))}for(let n=0;n<Math.min(e?.extendedAnsi?.length??0,240);n+=1){let r=e?.extendedAnsi?.[n];r!==void 0&&(t[n+16]=r)}return t}function bD(e){return`#${(e&16777215).toString(16).padStart(6,`0`)}`}function xD(e,t,n){return`#${e.toString(16).padStart(2,`0`)}${t.toString(16).padStart(2,`0`)}${n.toString(16).padStart(2,`0`)}`}var SD=`pi-webui.terminal.softKeys`,CD=`(pointer: coarse), (max-width: 760px)`;function wD(e,t){return e??t}function TD(e){if(e===`true`)return!0;if(e===`false`)return!1}function ED(){return typeof window<`u`&&`matchMedia`in window?window.matchMedia(CD):void 0}function DD(e){return e?.matches===!0}function OD(e=ED()){return wD(AD(),DD(e))}function kD(){return AD()!==void 0}function AD(e=MD()){if(e!==void 0)try{return TD(e.getItem(SD))}catch{return}}function jD(e,t=MD()){if(t!==void 0)try{t.setItem(SD,String(e))}catch{}}function MD(){if(!(typeof window>`u`))try{return window.localStorage}catch{return}}var ND=[{id:`escape`,label:`Esc`,ariaLabel:`Escape`,title:`Send Escape`},{id:`tab`,label:`Tab`,ariaLabel:`Tab`,title:`Send Tab`},{id:`ctrl-c`,label:`Ctrl+C`,ariaLabel:`Control C`,title:`Interrupt the foreground process`},{id:`ctrl-d`,label:`Ctrl+D`,ariaLabel:`Control D`,title:`Send EOF / close input`},{id:`ctrl-z`,label:`Ctrl+Z`,ariaLabel:`Control Z`,title:`Suspend the foreground process`},{id:`ctrl-l`,label:`Ctrl+L`,ariaLabel:`Control L`,title:`Clear / redraw the terminal`},{id:`ctrl-r`,label:`Ctrl+R`,ariaLabel:`Control R`,title:`Reverse search history`},{id:`ctrl-u`,label:`Ctrl+U`,ariaLabel:`Control U`,title:`Delete to the start of the line`},{id:`ctrl-w`,label:`Ctrl+W`,ariaLabel:`Control W`,title:`Delete the previous word`},{id:`arrow-left`,label:`←`,ariaLabel:`Left arrow`,title:`Move left`},{id:`arrow-up`,label:`↑`,ariaLabel:`Up arrow`,title:`Move up / previous command`},{id:`arrow-down`,label:`↓`,ariaLabel:`Down arrow`,title:`Move down / next command`},{id:`arrow-right`,label:`→`,ariaLabel:`Right arrow`,title:`Move right`},{id:`home`,label:`Home`,ariaLabel:`Home`,title:`Move to the start`},{id:`end`,label:`End`,ariaLabel:`End`,title:`Move to the end`},{id:`page-up`,label:`PgUp`,ariaLabel:`Page up`,title:`Page up`},{id:`page-down`,label:`PgDn`,ariaLabel:`Page down`,title:`Page down`},{id:`delete`,label:`Del`,ariaLabel:`Delete`,title:`Delete forward`},{id:`backspace`,label:`⌫`,ariaLabel:`Backspace`,title:`Backspace`},{id:`meta-backward-word`,label:`M-B`,ariaLabel:`Meta B`,title:`Move backward one word`},{id:`meta-forward-word`,label:`M-F`,ariaLabel:`Meta F`,title:`Move forward one word`}],PD=`\x1B`,FD=``;function ID(e,t){switch(e){case`escape`:return PD;case`tab`:return` `;case`ctrl-c`:return LD(`c`);case`ctrl-d`:return LD(`d`);case`ctrl-z`:return LD(`z`);case`ctrl-l`:return LD(`l`);case`ctrl-r`:return LD(`r`);case`ctrl-u`:return LD(`u`);case`ctrl-w`:return LD(`w`);case`arrow-left`:return RD(`D`,t);case`arrow-up`:return RD(`A`,t);case`arrow-down`:return RD(`B`,t);case`arrow-right`:return RD(`C`,t);case`home`:return zD(`H`,t);case`end`:return zD(`F`,t);case`page-up`:return`${PD}[5~`;case`page-down`:return`${PD}[6~`;case`delete`:return`${PD}[3~`;case`backspace`:return FD;case`meta-backward-word`:return`${PD}b`;case`meta-forward-word`:return`${PD}f`}}function LD(e){return String.fromCharCode(e.toUpperCase().charCodeAt(0)-64)}function RD(e,t){return t?.applicationCursorKeysMode===!0?`${PD}O${e}`:`${PD}[${e}`}function zD(e,t){return t?.applicationCursorKeysMode===!0?`${PD}O${e}`:`${PD}[${e}`}var BD=8,VD=500,HD=class extends y{constructor(...e){super(...e),this.refocusOnClick=!0,this.onInput=()=>void 0,this.lastPointerFinishedAt=0}sendSoftKey(e,t){this.onInput(ID(e.id,this.modes),t)}onSoftKeyPointerDown(e,t){e.pointerType===`mouse`&&e.button!==0||(e.preventDefault(),this.pointerStart={pointerId:e.pointerId,key:t,clientX:e.clientX,clientY:e.clientY})}onSoftKeyPointerMove(e){let t=this.pointerStart;t?.pointerId===e.pointerId&&UD(t,e)&&this.finishSoftKeyPointer()}onSoftKeyPointerUp(e,t){let n=this.pointerStart;n?.pointerId===e.pointerId&&(e.preventDefault(),this.finishSoftKeyPointer(),!(n.key.id!==t.id||UD(n,e))&&this.sendSoftKey(t,{refocus:e.pointerType===`mouse`}))}onSoftKeyPointerCancel(e){this.pointerStart?.pointerId===e.pointerId&&this.finishSoftKeyPointer()}finishSoftKeyPointer(){this.pointerStart=void 0,this.lastPointerFinishedAt=Date.now()}onSoftKeyClick(e,t){if(Date.now()-this.lastPointerFinishedAt<VD){e.preventDefault();return}this.sendSoftKey(t,{refocus:this.refocusOnClick})}render(){return g`
|
|
4816
4940
|
<div class="terminal-soft-keys" role="toolbar" aria-label="Terminal soft keys">
|
|
4817
|
-
${
|
|
4941
|
+
${ND.map(e=>g`
|
|
4818
4942
|
<button
|
|
4819
4943
|
type="button"
|
|
4820
4944
|
class="soft-key"
|
|
@@ -4834,7 +4958,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4834
4958
|
.terminal-soft-keys::-webkit-scrollbar { display: none; }
|
|
4835
4959
|
button { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; max-width: none; min-height: 34px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 6px 9px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; touch-action: pan-x; -webkit-touch-callout: none; user-select: none; }
|
|
4836
4960
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
4837
|
-
`}};B([x({attribute:!1})],LD.prototype,`modes`,void 0),B([x({type:Boolean})],LD.prototype,`refocusOnClick`,void 0),B([x({attribute:!1})],LD.prototype,`onInput`,void 0),LD=B([b(`terminal-soft-keys`)],LD);function RD(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)>FD}var zD=oe({TerminalPanel:()=>Z,filterTerminalInput:()=>ZD,terminalBackgroundWithOpacity:()=>rO}),BD={allowTransparency:!0,cursorBlink:!0,convertEol:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13},VD={cols:100,rows:30},HD=1e3,UD=`--pi-terminal-effective-bg`,WD=`--pi-terminal-ui-opacity`,Z=class extends y{constructor(...e){super(...e),this.machineId=`local`,this.autoStart=!1,this.fontSize=13,this.bgOpacity=100,this.onSelectTerminal=()=>void 0,this.terminals=[],this.commandRuns=[],this.loading=!1,this.visible=!1,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.defaultSoftKeysEnvironment=!1,this.softKeysEnabled=CD(),this.suppressTerminalInput=!1,this.softKeysDefaultEnvironmentMedia=xD(),this.softKeysPreferenceStored=wD(),this.onSoftKeysDefaultEnvironmentChange=()=>{this.syncDefaultSoftKeysEnvironment()}}connectedCallback(){super.connectedCallback(),this.syncTerminalBackground(),this.syncDefaultSoftKeysEnvironment(),this.softKeysDefaultEnvironmentMedia?.addEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.themeObserver=new MutationObserver(()=>{this.applyTerminalTheme()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]})}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting===!0}),this.intersectionObserver.observe(this)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.themeObserver?.disconnect(),this.themeObserver=void 0,this.softKeysDefaultEnvironmentMedia?.removeEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.updateCommandRunPolling(!1),this.disposeTerminalView(),super.disconnectedCallback()}syncDefaultSoftKeysEnvironment(){let e=SD(this.softKeysDefaultEnvironmentMedia),t=this.softKeysEnabled;this.defaultSoftKeysEnvironment=e,this.softKeysPreferenceStored||(this.softKeysEnabled=e),this.softKeysEnabled!==t&&this.scheduleFitAndNotify()}scheduleFitAndNotify(){this.updateComplete.then(()=>{this.fitAndNotify()})}willUpdate(e){e.has(`bgOpacity`)&&this.syncTerminalBackground();let t=this.workspace===void 0?void 0:JSON.stringify([this.machineId,this.workspace.path]);if(t!==this.observedWorkspaceScope){this.observedWorkspaceScope=t,this.loadedCwd=void 0,this.autoStartConsumedCwd=void 0,this.terminals=[],this.commandRuns=[],this.selectedId=void 0,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.updateCommandRunPolling(!1),this.disposeTerminalView();return}if(e.has(`selectedTerminalId`)){if(e.get(`selectedTerminalId`)!==void 0&&this.selectedTerminalId===void 0){this.loadedCwd=void 0,this.selectTerminalIdInView(void 0);return}this.applyRequestedTerminalSelection()}}updated(e){this.visible?this.hasPendingCommandRuns()&&this.updateCommandRunPolling(!0):this.updateCommandRunPolling(!1),this.loadVisibleWorkspaceTerminals(),e.has(`selectedTerminalId`)&&this.shouldReloadForRequestedTerminal()&&this.loadTerminals(),e.has(`fontSize`)&&this.terminal!==void 0&&(this.terminal.options.fontSize=this.fontSize,this.fitAndNotify()),e.has(`bgOpacity`)&&this.applyTerminalTheme(),this.ensureTerminalView()}loadVisibleWorkspaceTerminals(){let e=this.workspace?.path;!this.visible||e===void 0||e===this.loadedCwd||(this.loadedCwd=e,this.loadTerminals())}async loadTerminals(){this.loading=!0,this.error=void 0;try{let e=this.workspace;if(e===void 0)return;let t=this.consumeAutoStart(),[n,r]=await Promise.all([ao.terminals(e.projectId,e.id,this.machineId),ao.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId)]);this.terminals=n,this.commandRuns=r,this.selectPreferredLoadedTerminal({replaceUrl:!0}),this.updateCommandRunPolling(this.hasPendingCommandRuns(r)),n.length===0&&t&&await this.startTerminal()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.loading=!1}}applyRequestedTerminalSelection(){this.selectedTerminalId!==void 0&&!this.terminals.some(e=>e.id===this.selectedTerminalId)||this.selectPreferredLoadedTerminal({replaceUrl:!0})}consumeAutoStart(){let e=this.workspace?.path;return!this.autoStart||e===void 0||this.autoStartConsumedCwd===e?!1:(this.autoStartConsumedCwd=e,!0)}shouldReloadForRequestedTerminal(){let e=this.workspace?.path;return this.visible&&e!==void 0&&e===this.loadedCwd&&this.selectedTerminalId!==void 0&&!this.loading&&!this.terminals.some(e=>e.id===this.selectedTerminalId)}selectPreferredLoadedTerminal(e){let t=ef(this.terminals,{targetTerminalId:this.selectedTerminalId});t===void 0&&this.selectedTerminalId!==void 0&&(t=tf(this.terminals)),this.selectTerminalIdInView(t?.id),(t?.id!==this.selectedTerminalId||t===void 0&&this.selectedTerminalId!==void 0)&&this.onSelectTerminal(t?.id,{replace:e?.replaceUrl===!0})}selectTerminalIdInView(e){this.selectedId!==e&&(this.selectedId=e,this.disposeTerminalView())}async startTerminal(){if(this.workspace!==void 0){this.error=void 0;try{let e=this.measureTerminalSize()??VD,t=await ao.startTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=[...this.terminals,t],this.selectTerminal(t.id)}catch(e){this.error=e instanceof Error?e.message:String(e)}}}async closeTerminal(e,t){t.stopPropagation();try{if(this.workspace===void 0)return;await ao.closeTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);let t=this.terminals.filter(t=>t.id!==e);if(this.terminals=t,this.selectedId===e||this.selectedTerminalId===e){let e=tf(t)?.id;this.selectTerminalIdInView(e),this.onSelectTerminal(e,{replace:!0})}}catch(e){this.error=e instanceof Error?e.message:String(e)}}selectTerminal(e){this.selectedId!==e&&this.selectTerminalIdInView(e),this.onSelectTerminal(e)}selectedTerminalInfo(){return this.terminals.find(e=>e.id===this.selectedId)}selectedCommandRun(){let e=this.selectedTerminalInfo()?.commandRunId;if(e!==void 0)return this.commandRuns.find(t=>t.id===e)}async loadCommandRuns(){let e=this.workspace;if(e!==void 0)try{let t=await ao.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId);this.commandRuns=t,this.cancellingRunIds=this.cancellingRunIds.filter(e=>t.some(t=>t.id===e&&JD(t))),this.updateCommandRunPolling(this.hasPendingCommandRuns(t))}catch(e){this.error=e instanceof Error?e.message:String(e)}}updateCommandRunPolling(e){if(e&&this.commandRunPollTimer===void 0){this.commandRunPollTimer=window.setInterval(()=>{this.loadCommandRuns()},HD);return}!e&&this.commandRunPollTimer!==void 0&&(window.clearInterval(this.commandRunPollTimer),this.commandRunPollTimer=void 0)}hasPendingCommandRuns(e=this.commandRuns){return e.some(JD)}async cancelCommandRun(e){if(!(!JD(e)||this.cancellingRunIds.includes(e.id))){this.error=void 0,this.cancellingRunIds=[...this.cancellingRunIds,e.id];try{await ao.cancelCommandRun(e.id,this.machineId),await this.loadCommandRuns()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.cancellingRunIds=this.cancellingRunIds.filter(t=>t!==e.id)}}}async continueTerminal(e){if(!(this.workspace===void 0||this.continuingTerminalIds.includes(e))){this.error=void 0,this.continuingTerminalIds=[...this.continuingTerminalIds,e];try{let t=await ao.continueTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=this.terminals.map(n=>n.id===e?t:n),this.socket===void 0&&this.disposeTerminalView(),this.fitAndNotify(),this.terminal?.focus()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.continuingTerminalIds=this.continuingTerminalIds.filter(t=>t!==e)}}}ensureTerminalView(){let e=this.workspace,t=this.terminalHostElement();if(!this.visible||this.terminal!==void 0||this.selectedId===void 0||t===void 0||e===void 0)return;let n=new re($D(this)),r=new ie;n.loadAddon(r),n.open(t),this.terminal=n,this.fitAddon=r,this.resizeObserver=new ResizeObserver(()=>{this.fitAndNotify()}),this.resizeObserver.observe(t),n.onData(e=>{this.suppressTerminalInput||this.copySnapshot!==void 0||this.sendTerminalInput(e)});let i=this.fitTerminal();this.connectSocket(e.projectId,e.id,this.selectedId,n,i),requestAnimationFrame(()=>{this.fitAndNotify()}),n.focus()}connectSocket(e,t,n,r,i){let a=mo(e,t,n,i,this.machineId);a.binaryType=`arraybuffer`,this.socket=a,a.addEventListener(`open`,()=>{this.fitAndNotify()}),a.addEventListener(`message`,e=>{this.handleSocketMessage(e.data,n,r)}),a.addEventListener(`close`,()=>{this.socket===a&&(this.socket=void 0)})}async handleSocketMessage(e,t,n){try{let r=XD(await QD(e));r.type===`output`&&this.writeTerminalOutput(n,r.data,r.replay===!0),r.type===`exit`&&(n.writeln(`\r\n[process exited${r.exitCode===void 0?``:` with code ${String(r.exitCode)}`}]`),this.terminals=this.terminals.map(e=>e.id===t?{...e,exited:!0,...r.exitCode===void 0?{}:{exitCode:r.exitCode}}:e),this.loadCommandRuns()),r.type===`error`&&n.writeln(`\r\n[terminal error: ${r.message}]`)}catch(e){n.writeln(`\r\n[terminal error: ${e instanceof Error?e.message:String(e)}]`)}}writeTerminalOutput(e,t,n){if(!n){e.write(t);return}this.suppressTerminalInput=!0,e.write(t,()=>{this.suppressTerminalInput=!1})}fitAndNotify(){let e=this.fitTerminal();e!==void 0&&this.send({type:`resize`,...e})}fitTerminal(){if(this.fitAddon===void 0||this.terminal===void 0)return;let e=iO(this.fitAddon.proposeDimensions());if(e!==void 0)return this.fitAddon.fit(),e}measureTerminalSize(){let e=this.fitTerminal();if(e!==void 0)return e;let t=this.terminalHostElement();if(this.terminal!==void 0||t===void 0)return;let n=new re($D(this)),r=new ie;n.loadAddon(r),n.open(t);let i=iO(r.proposeDimensions());return n.dispose(),i}terminalHostElement(){let e=this.terminalHost;return e instanceof HTMLDivElement?e:void 0}applyTerminalTheme(){this.syncTerminalBackground(),this.terminal!==void 0&&(this.terminal.options.theme=eO(this))}syncTerminalBackground(){let e=nO(this.bgOpacity),t=rO(tO(this,`--pi-terminal-bg`,`#05070a`),e);this.style.setProperty(UD,t),this.style.setProperty(WD,`${String(e)}%`)}sendTerminalInput(e){let t=ZD(e);t!==``&&this.send({type:`input`,data:t})}sendSoftKeyInput(e,t){this.copySnapshot===void 0&&(this.sendTerminalInput(e),t.refocus&&this.focusTerminal())}focusTerminal(){let e=this.terminal;e!==void 0&&(e.focus(),requestAnimationFrame(()=>{e.focus()}))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}disposeTerminalView(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.socket?.close(),this.socket=void 0,this.terminal?.dispose(),this.terminal=void 0,this.fitAddon=void 0,this.copySnapshot=void 0,this.copyStatus=void 0}renderCommandRunNotice(){let e=this.selectedCommandRun();if(e===void 0)return null;let t=this.selectedTerminalInfo();if(JD(e)){let t=this.cancellingRunIds.includes(e.id);return g`
|
|
4961
|
+
`}};B([x({attribute:!1})],HD.prototype,`modes`,void 0),B([x({type:Boolean})],HD.prototype,`refocusOnClick`,void 0),B([x({attribute:!1})],HD.prototype,`onInput`,void 0),HD=B([b(`terminal-soft-keys`)],HD);function UD(e,t){return Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)>BD}var WD=oe({TerminalPanel:()=>Z,filterTerminalInput:()=>nO,terminalBackgroundWithOpacity:()=>cO}),GD={allowTransparency:!0,cursorBlink:!0,convertEol:!0,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:13},KD={cols:100,rows:30},qD=1e3,JD=`--pi-terminal-effective-bg`,YD=`--pi-terminal-ui-opacity`,Z=class extends y{constructor(...e){super(...e),this.machineId=`local`,this.autoStart=!1,this.fontSize=13,this.bgOpacity=100,this.onSelectTerminal=()=>void 0,this.terminals=[],this.commandRuns=[],this.loading=!1,this.visible=!1,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.defaultSoftKeysEnvironment=!1,this.softKeysEnabled=OD(),this.suppressTerminalInput=!1,this.softKeysDefaultEnvironmentMedia=ED(),this.softKeysPreferenceStored=kD(),this.onSoftKeysDefaultEnvironmentChange=()=>{this.syncDefaultSoftKeysEnvironment()}}connectedCallback(){super.connectedCallback(),this.syncTerminalBackground(),this.syncDefaultSoftKeysEnvironment(),this.softKeysDefaultEnvironmentMedia?.addEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.themeObserver=new MutationObserver(()=>{this.applyTerminalTheme()}),this.themeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`]})}firstUpdated(){this.intersectionObserver=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting===!0}),this.intersectionObserver.observe(this)}disconnectedCallback(){this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.themeObserver?.disconnect(),this.themeObserver=void 0,this.softKeysDefaultEnvironmentMedia?.removeEventListener(`change`,this.onSoftKeysDefaultEnvironmentChange),this.updateCommandRunPolling(!1),this.disposeTerminalView(),super.disconnectedCallback()}syncDefaultSoftKeysEnvironment(){let e=DD(this.softKeysDefaultEnvironmentMedia),t=this.softKeysEnabled;this.defaultSoftKeysEnvironment=e,this.softKeysPreferenceStored||(this.softKeysEnabled=e),this.softKeysEnabled!==t&&this.scheduleFitAndNotify()}scheduleFitAndNotify(){this.updateComplete.then(()=>{this.fitAndNotify()})}willUpdate(e){e.has(`bgOpacity`)&&this.syncTerminalBackground();let t=this.workspace===void 0?void 0:JSON.stringify([this.machineId,this.workspace.path]);if(t!==this.observedWorkspaceScope){this.observedWorkspaceScope=t,this.loadedCwd=void 0,this.autoStartConsumedCwd=void 0,this.terminals=[],this.commandRuns=[],this.selectedId=void 0,this.cancellingRunIds=[],this.continuingTerminalIds=[],this.updateCommandRunPolling(!1),this.disposeTerminalView();return}if(e.has(`selectedTerminalId`)){if(e.get(`selectedTerminalId`)!==void 0&&this.selectedTerminalId===void 0){this.loadedCwd=void 0,this.selectTerminalIdInView(void 0);return}this.applyRequestedTerminalSelection()}}updated(e){this.visible?this.hasPendingCommandRuns()&&this.updateCommandRunPolling(!0):this.updateCommandRunPolling(!1),this.loadVisibleWorkspaceTerminals(),e.has(`selectedTerminalId`)&&this.shouldReloadForRequestedTerminal()&&this.loadTerminals(),e.has(`fontSize`)&&this.terminal!==void 0&&(this.terminal.options.fontSize=this.fontSize,this.fitAndNotify()),e.has(`bgOpacity`)&&this.applyTerminalTheme(),this.ensureTerminalView()}loadVisibleWorkspaceTerminals(){let e=this.workspace?.path;!this.visible||e===void 0||e===this.loadedCwd||(this.loadedCwd=e,this.loadTerminals())}async loadTerminals(){this.loading=!0,this.error=void 0;try{let e=this.workspace;if(e===void 0)return;let t=this.consumeAutoStart(),[n,r]=await Promise.all([ao.terminals(e.projectId,e.id,this.machineId),ao.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId)]);this.terminals=n,this.commandRuns=r,this.selectPreferredLoadedTerminal({replaceUrl:!0}),this.updateCommandRunPolling(this.hasPendingCommandRuns(r)),n.length===0&&t&&await this.startTerminal()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.loading=!1}}applyRequestedTerminalSelection(){this.selectedTerminalId!==void 0&&!this.terminals.some(e=>e.id===this.selectedTerminalId)||this.selectPreferredLoadedTerminal({replaceUrl:!0})}consumeAutoStart(){let e=this.workspace?.path;return!this.autoStart||e===void 0||this.autoStartConsumedCwd===e?!1:(this.autoStartConsumedCwd=e,!0)}shouldReloadForRequestedTerminal(){let e=this.workspace?.path;return this.visible&&e!==void 0&&e===this.loadedCwd&&this.selectedTerminalId!==void 0&&!this.loading&&!this.terminals.some(e=>e.id===this.selectedTerminalId)}selectPreferredLoadedTerminal(e){let t=ef(this.terminals,{targetTerminalId:this.selectedTerminalId});t===void 0&&this.selectedTerminalId!==void 0&&(t=tf(this.terminals)),this.selectTerminalIdInView(t?.id),(t?.id!==this.selectedTerminalId||t===void 0&&this.selectedTerminalId!==void 0)&&this.onSelectTerminal(t?.id,{replace:e?.replaceUrl===!0})}selectTerminalIdInView(e){this.selectedId!==e&&(this.selectedId=e,this.disposeTerminalView())}async startTerminal(){if(this.workspace!==void 0){this.error=void 0;try{let e=this.measureTerminalSize()??KD,t=await ao.startTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=[...this.terminals,t],this.selectTerminal(t.id)}catch(e){this.error=e instanceof Error?e.message:String(e)}}}async closeTerminal(e,t){t.stopPropagation();try{if(this.workspace===void 0)return;await ao.closeTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);let t=this.terminals.filter(t=>t.id!==e);if(this.terminals=t,this.selectedId===e||this.selectedTerminalId===e){let e=tf(t)?.id;this.selectTerminalIdInView(e),this.onSelectTerminal(e,{replace:!0})}}catch(e){this.error=e instanceof Error?e.message:String(e)}}selectTerminal(e){this.selectedId!==e&&this.selectTerminalIdInView(e),this.onSelectTerminal(e)}selectedTerminalInfo(){return this.terminals.find(e=>e.id===this.selectedId)}selectedCommandRun(){let e=this.selectedTerminalInfo()?.commandRunId;if(e!==void 0)return this.commandRuns.find(t=>t.id===e)}async loadCommandRuns(){let e=this.workspace;if(e!==void 0)try{let t=await ao.listCommandRuns({projectId:e.projectId,workspaceId:e.id},this.machineId);this.commandRuns=t,this.cancellingRunIds=this.cancellingRunIds.filter(e=>t.some(t=>t.id===e&&$D(t))),this.updateCommandRunPolling(this.hasPendingCommandRuns(t))}catch(e){this.error=e instanceof Error?e.message:String(e)}}updateCommandRunPolling(e){if(e&&this.commandRunPollTimer===void 0){this.commandRunPollTimer=window.setInterval(()=>{this.loadCommandRuns()},qD);return}!e&&this.commandRunPollTimer!==void 0&&(window.clearInterval(this.commandRunPollTimer),this.commandRunPollTimer=void 0)}hasPendingCommandRuns(e=this.commandRuns){return e.some($D)}async cancelCommandRun(e){if(!(!$D(e)||this.cancellingRunIds.includes(e.id))){this.error=void 0,this.cancellingRunIds=[...this.cancellingRunIds,e.id];try{await ao.cancelCommandRun(e.id,this.machineId),await this.loadCommandRuns()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.cancellingRunIds=this.cancellingRunIds.filter(t=>t!==e.id)}}}async continueTerminal(e){if(!(this.workspace===void 0||this.continuingTerminalIds.includes(e))){this.error=void 0,this.continuingTerminalIds=[...this.continuingTerminalIds,e];try{let t=await ao.continueTerminal(this.workspace.projectId,this.workspace.id,e,this.machineId);this.terminals=this.terminals.map(n=>n.id===e?t:n),this.socket===void 0&&this.disposeTerminalView(),this.fitAndNotify(),this.terminal?.focus()}catch(e){this.error=e instanceof Error?e.message:String(e)}finally{this.continuingTerminalIds=this.continuingTerminalIds.filter(t=>t!==e)}}}ensureTerminalView(){let e=this.workspace,t=this.terminalHostElement();if(!this.visible||this.terminal!==void 0||this.selectedId===void 0||t===void 0||e===void 0)return;let n=new re(iO(this)),r=new ie;n.loadAddon(r),n.open(t),this.terminal=n,this.fitAddon=r,this.resizeObserver=new ResizeObserver(()=>{this.fitAndNotify()}),this.resizeObserver.observe(t),n.onData(e=>{this.suppressTerminalInput||this.copySnapshot!==void 0||this.sendTerminalInput(e)});let i=this.fitTerminal();this.connectSocket(e.projectId,e.id,this.selectedId,n,i),requestAnimationFrame(()=>{this.fitAndNotify()}),n.focus()}connectSocket(e,t,n,r,i){let a=mo(e,t,n,i,this.machineId);a.binaryType=`arraybuffer`,this.socket=a,a.addEventListener(`open`,()=>{this.fitAndNotify()}),a.addEventListener(`message`,e=>{this.handleSocketMessage(e.data,n,r)}),a.addEventListener(`close`,()=>{this.socket===a&&(this.socket=void 0)})}async handleSocketMessage(e,t,n){try{let r=tO(await rO(e));r.type===`output`&&this.writeTerminalOutput(n,r.data,r.replay===!0),r.type===`exit`&&(n.writeln(`\r\n[process exited${r.exitCode===void 0?``:` with code ${String(r.exitCode)}`}]`),this.terminals=this.terminals.map(e=>e.id===t?{...e,exited:!0,...r.exitCode===void 0?{}:{exitCode:r.exitCode}}:e),this.loadCommandRuns()),r.type===`error`&&n.writeln(`\r\n[terminal error: ${r.message}]`)}catch(e){n.writeln(`\r\n[terminal error: ${e instanceof Error?e.message:String(e)}]`)}}writeTerminalOutput(e,t,n){if(!n){e.write(t);return}this.suppressTerminalInput=!0,e.write(t,()=>{this.suppressTerminalInput=!1})}fitAndNotify(){let e=this.fitTerminal();e!==void 0&&this.send({type:`resize`,...e})}fitTerminal(){if(this.fitAddon===void 0||this.terminal===void 0)return;let e=lO(this.fitAddon.proposeDimensions());if(e!==void 0)return this.fitAddon.fit(),e}measureTerminalSize(){let e=this.fitTerminal();if(e!==void 0)return e;let t=this.terminalHostElement();if(this.terminal!==void 0||t===void 0)return;let n=new re(iO(this)),r=new ie;n.loadAddon(r),n.open(t);let i=lO(r.proposeDimensions());return n.dispose(),i}terminalHostElement(){let e=this.terminalHost;return e instanceof HTMLDivElement?e:void 0}applyTerminalTheme(){this.syncTerminalBackground(),this.terminal!==void 0&&(this.terminal.options.theme=aO(this))}syncTerminalBackground(){let e=sO(this.bgOpacity),t=cO(oO(this,`--pi-terminal-bg`,`#05070a`),e);this.style.setProperty(JD,t),this.style.setProperty(YD,`${String(e)}%`)}sendTerminalInput(e){let t=nO(e);t!==``&&this.send({type:`input`,data:t})}sendSoftKeyInput(e,t){this.copySnapshot===void 0&&(this.sendTerminalInput(e),t.refocus&&this.focusTerminal())}focusTerminal(){let e=this.terminal;e!==void 0&&(e.focus(),requestAnimationFrame(()=>{e.focus()}))}send(e){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify(e))}disposeTerminalView(){this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.socket?.close(),this.socket=void 0,this.terminal?.dispose(),this.terminal=void 0,this.fitAddon=void 0,this.copySnapshot=void 0,this.copyStatus=void 0}renderCommandRunNotice(){let e=this.selectedCommandRun();if(e===void 0)return null;let t=this.selectedTerminalInfo();if($D(e)){let t=this.cancellingRunIds.includes(e.id);return g`
|
|
4838
4962
|
<section class="command-run-notice running">
|
|
4839
4963
|
<div>
|
|
4840
4964
|
<strong>${e.title}</strong>
|
|
@@ -4846,13 +4970,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4846
4970
|
`}if(t?.exited===!0){let n=this.continuingTerminalIds.includes(t.id);return g`
|
|
4847
4971
|
<section class=${`command-run-notice ${e.status}`}>
|
|
4848
4972
|
<div>
|
|
4849
|
-
<strong>${
|
|
4973
|
+
<strong>${eO(e)}</strong>
|
|
4850
4974
|
<p>Output is preserved. Continue in a shell to inspect or run follow-up commands.</p>
|
|
4851
4975
|
<code>${e.command}</code>
|
|
4852
4976
|
</div>
|
|
4853
4977
|
<button ?disabled=${n} @click=${()=>{this.continueTerminal(t.id)}}>${n?`Starting shell…`:`Continue in shell`}</button>
|
|
4854
4978
|
</section>
|
|
4855
|
-
`}return null}enterCopyMode(){this.copySnapshot===void 0&&this.captureCopySnapshot()}refreshCopyMode(){this.copySnapshot!==void 0&&this.captureCopySnapshot()}captureCopySnapshot(){let e=this.terminal;if(e===void 0)return;let t=
|
|
4979
|
+
`}return null}enterCopyMode(){this.copySnapshot===void 0&&this.captureCopySnapshot()}refreshCopyMode(){this.copySnapshot!==void 0&&this.captureCopySnapshot()}captureCopySnapshot(){let e=this.terminal;if(e===void 0)return;let t=dD(e.buffer.active,e.cols,{theme:e.options.theme,drawBoldTextInBrightColors:e.options.drawBoldTextInBrightColors});this.copySnapshot=t,this.copyStatus=void 0,e.blur(),this.updateComplete.then(()=>{let n=this.terminalCopySelector;if(n==null)return;let r=Math.max(0,t.physicalLineCount-e.rows),i=Math.min(r,t.viewportLine);n.scrollTop=(r===0?0:i/r)*Math.max(0,n.scrollHeight-n.clientHeight),this.syncCopySnapshotScroll()})}exitCopyMode(){this.copySnapshot!==void 0&&(this.copySnapshot=void 0,this.copyStatus=void 0)}syncCopySnapshotScroll(){let e=this.terminalCopySelector,t=this.terminalCopyContent;if(e==null||t==null)return;let n=Math.max(0,e.scrollHeight-e.clientHeight),r=Math.max(0,t.scrollHeight-t.clientHeight),i=Math.max(0,e.scrollWidth-e.clientWidth),a=Math.max(0,t.scrollWidth-t.clientWidth);t.scrollTop=XD(e.scrollTop,n,r),t.scrollLeft=XD(e.scrollLeft,i,a)}async copyAllSnapshotText(){let e=this.copySnapshot?.text??``;if(e===``){this.copyStatus=`No terminal output to copy.`;return}this.copyStatus=await Wv(e)?`Copied all terminal output.`:`Unable to copy terminal output.`}renderCopyModeToggle(){if(this.selectedId===void 0)return null;let e=this.copySnapshot!==void 0;return g`
|
|
4856
4980
|
<button
|
|
4857
4981
|
type="button"
|
|
4858
4982
|
class=${e?`copy-mode-toggle selected`:`copy-mode-toggle`}
|
|
@@ -4875,7 +4999,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4875
4999
|
${this.copyToolbarReplacesSoftKeys()?null:this.renderCopyModeToolbar()}
|
|
4876
5000
|
<div class="terminal-copy-layers">
|
|
4877
5001
|
<pre class="terminal-copy-content" aria-hidden="true">${e.lines.map((e,t)=>g`${t===0?null:`
|
|
4878
|
-
`}${e.runs.map(e=>g`<span style=${
|
|
5002
|
+
`}${e.runs.map(e=>g`<span style=${aD(QD(e.style))}>${e.text}</span>`)}`)}</pre>
|
|
4879
5003
|
<textarea
|
|
4880
5004
|
class="terminal-copy-selector"
|
|
4881
5005
|
readonly
|
|
@@ -4890,7 +5014,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
4890
5014
|
></textarea>
|
|
4891
5015
|
</div>
|
|
4892
5016
|
</section>
|
|
4893
|
-
`}selectedTerminalAcceptsInput(){let e=this.selectedTerminalInfo();return e!==void 0&&!e.exited}copyToolbarReplacesSoftKeys(){return this.copySnapshot!==void 0&&this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}renderTerminalAccessoryBar(){return this.copySnapshot===void 0?this.shouldShowSoftKeys()?this.renderSoftKeys():null:this.copyToolbarReplacesSoftKeys()?this.renderCopyModeToolbar():null}shouldShowSoftKeys(){return this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}shouldShowSoftKeysToggle(){return this.copySnapshot===void 0&&this.selectedTerminalAcceptsInput()}toggleSoftKeys(){this.copySnapshot===void 0&&(this.softKeysEnabled=!this.softKeysEnabled,this.softKeysPreferenceStored=!0,
|
|
5017
|
+
`}selectedTerminalAcceptsInput(){let e=this.selectedTerminalInfo();return e!==void 0&&!e.exited}copyToolbarReplacesSoftKeys(){return this.copySnapshot!==void 0&&this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}renderTerminalAccessoryBar(){return this.copySnapshot===void 0?this.shouldShowSoftKeys()?this.renderSoftKeys():null:this.copyToolbarReplacesSoftKeys()?this.renderCopyModeToolbar():null}shouldShowSoftKeys(){return this.selectedTerminalAcceptsInput()&&this.softKeysEnabled}shouldShowSoftKeysToggle(){return this.copySnapshot===void 0&&this.selectedTerminalAcceptsInput()}toggleSoftKeys(){this.copySnapshot===void 0&&(this.softKeysEnabled=!this.softKeysEnabled,this.softKeysPreferenceStored=!0,jD(this.softKeysEnabled),this.scheduleFitAndNotify())}renderSoftKeysToggle(){return this.shouldShowSoftKeysToggle()?g`
|
|
4894
5018
|
<button
|
|
4895
5019
|
type="button"
|
|
4896
5020
|
class=${this.softKeysEnabled?`soft-keys-toggle selected`:`soft-keys-toggle`}
|
|
@@ -5011,32 +5135,32 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5011
5135
|
.error { flex: 0 0 auto; margin: 0; padding: 8px; color: var(--pi-danger); border-bottom: 1px solid var(--pi-border); background: color-mix(in srgb, var(--pi-surface) var(--pi-terminal-ui-opacity, 100%), transparent); }
|
|
5012
5136
|
.muted { margin: 10px; color: var(--pi-muted); }
|
|
5013
5137
|
.xterm { height: 100%; }
|
|
5014
|
-
`}};B([x({attribute:!1})],Z.prototype,`workspace`,void 0),B([x()],Z.prototype,`machineId`,void 0),B([x({attribute:!1})],Z.prototype,`selectedTerminalId`,void 0),B([x({type:Boolean})],Z.prototype,`autoStart`,void 0),B([x({type:Number})],Z.prototype,`fontSize`,void 0),B([x({type:Number})],Z.prototype,`bgOpacity`,void 0),B([x({attribute:!1})],Z.prototype,`onSelectTerminal`,void 0),B([C(`.terminal-host`)],Z.prototype,`terminalHost`,void 0),B([C(`.terminal-copy-content`)],Z.prototype,`terminalCopyContent`,void 0),B([C(`.terminal-copy-selector`)],Z.prototype,`terminalCopySelector`,void 0),B([S()],Z.prototype,`terminals`,void 0),B([S()],Z.prototype,`commandRuns`,void 0),B([S()],Z.prototype,`selectedId`,void 0),B([S()],Z.prototype,`loading`,void 0),B([S()],Z.prototype,`error`,void 0),B([S()],Z.prototype,`visible`,void 0),B([S()],Z.prototype,`cancellingRunIds`,void 0),B([S()],Z.prototype,`continuingTerminalIds`,void 0),B([S()],Z.prototype,`defaultSoftKeysEnvironment`,void 0),B([S()],Z.prototype,`softKeysEnabled`,void 0),B([S()],Z.prototype,`copySnapshot`,void 0),B([S()],Z.prototype,`copyStatus`,void 0),Z=B([b(`terminal-panel`)],Z);function
|
|
5138
|
+
`}};B([x({attribute:!1})],Z.prototype,`workspace`,void 0),B([x()],Z.prototype,`machineId`,void 0),B([x({attribute:!1})],Z.prototype,`selectedTerminalId`,void 0),B([x({type:Boolean})],Z.prototype,`autoStart`,void 0),B([x({type:Number})],Z.prototype,`fontSize`,void 0),B([x({type:Number})],Z.prototype,`bgOpacity`,void 0),B([x({attribute:!1})],Z.prototype,`onSelectTerminal`,void 0),B([C(`.terminal-host`)],Z.prototype,`terminalHost`,void 0),B([C(`.terminal-copy-content`)],Z.prototype,`terminalCopyContent`,void 0),B([C(`.terminal-copy-selector`)],Z.prototype,`terminalCopySelector`,void 0),B([S()],Z.prototype,`terminals`,void 0),B([S()],Z.prototype,`commandRuns`,void 0),B([S()],Z.prototype,`selectedId`,void 0),B([S()],Z.prototype,`loading`,void 0),B([S()],Z.prototype,`error`,void 0),B([S()],Z.prototype,`visible`,void 0),B([S()],Z.prototype,`cancellingRunIds`,void 0),B([S()],Z.prototype,`continuingTerminalIds`,void 0),B([S()],Z.prototype,`defaultSoftKeysEnvironment`,void 0),B([S()],Z.prototype,`softKeysEnabled`,void 0),B([S()],Z.prototype,`copySnapshot`,void 0),B([S()],Z.prototype,`copyStatus`,void 0),Z=B([b(`terminal-panel`)],Z);function XD(e,t,n){return t<=0||n<=0?0:Math.min(1,Math.max(0,e/t))*n}function ZD(e){return/^#[\da-f]{6}$/i.test(e)?`${e}80`:`color-mix(in srgb, ${e} 50%, transparent)`}function QD(e){let t=[e.underline?`underline`:void 0,e.strikethrough?`line-through`:void 0,e.overline?`overline`:void 0].filter(e=>e!==void 0).join(` `);return{color:e.invisible?`transparent`:e.dim?ZD(e.foreground):e.foreground,backgroundColor:e.background,fontWeight:e.bold?`700`:void 0,fontStyle:e.italic?`italic`:void 0,textDecorationLine:t===``?void 0:t}}function $D(e){return e.status===`queued`||e.status===`running`}function eO(e){return e.status===`succeeded`?`Command succeeded${e.exitCode===void 0?``:` with exit code ${String(e.exitCode)}`}`:`Command failed${e.exitCode===void 0?``:` with exit code ${String(e.exitCode)}`}`}function tO(e){let t=JSON.parse(e);if(!dO(t))return{type:`error`,message:`Invalid terminal message`};let n=t;return n.type===`output`&&typeof n.data==`string`?{type:`output`,data:n.data,...typeof n.replay==`boolean`?{replay:n.replay}:{}}:n.type===`exit`?{type:`exit`,...typeof n.exitCode==`number`?{exitCode:n.exitCode}:{}}:n.type===`error`&&typeof n.message==`string`?{type:`error`,message:n.message}:{type:`error`,message:`Invalid terminal message`}}function nO(e){return e.replaceAll(`\x1B[I`,``).replaceAll(`\x1B[O`,``)}async function rO(e){return typeof e==`string`?e:e instanceof ArrayBuffer?new TextDecoder().decode(e):e instanceof Blob?await e.text():String(e)}function iO(e){let t=GD;return e instanceof Z?{...t,fontSize:e.fontSize,theme:aO(e)}:{...t,theme:aO(e)}}function aO(e){let t=cO(oO(e,`--pi-terminal-bg`,`#05070a`),e instanceof Z?e.bgOpacity:100);return{...uD,background:t,foreground:oO(e,`--pi-terminal-text`,`#e6edf3`),cursor:oO(e,`--pi-accent`,`#58a6ff`),selectionBackground:oO(e,`--pi-terminal-selection`,`#264f78`)}}function oO(e,t,n){let r=getComputedStyle(e).getPropertyValue(t).trim();return r===``?n:r}function sO(e){return Math.max(0,Math.min(100,e))}function cO(e,t){let n=sO(t)/100;if(n>=1||e===`transparent`)return e;let r=/^#([\da-f]{3}|[\da-f]{6})$/iu.exec(e);if(r===null)return e;let i=r[1]??``,[a=`00`,o=`00`,s=`00`]=i.length===3?[i.charAt(0).repeat(2),i.charAt(1).repeat(2),i.charAt(2).repeat(2)]:[i.slice(0,2),i.slice(2,4),i.slice(4,6)];return`rgba(${String(parseInt(a,16))}, ${String(parseInt(o,16))}, ${String(parseInt(s,16))}, ${String(n)})`}function lO(e){if(!(e===void 0||!uO(e.cols,e.rows)))return{cols:Math.floor(e.cols),rows:Math.floor(e.rows)}}function uO(e,t){return Number.isFinite(e)&&Number.isFinite(t)&&e>0&&t>0}function dO(e){return typeof e==`object`&&!!e}var fO=class extends y{constructor(...e){super(...e),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(){let e=pO(this.machines),t=mO(this.machine),n=gO(this.project),r=vO(this.workspace),i=bO(this.session);return g`
|
|
5015
5139
|
<nav class=${this.contextBarClass()} aria-label="Current location">
|
|
5016
5140
|
<span class="context-bar-label">Location</span>
|
|
5017
5141
|
<ol class="context-items" @scroll=${this.onContextScroll}>
|
|
5018
5142
|
${e?g`
|
|
5019
5143
|
<li class="context-item">
|
|
5020
|
-
<button type="button" class=${this.machine===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5144
|
+
<button type="button" class=${this.machine===void 0?`context-chip empty`:`context-chip`} title=${hO(this.machine)} aria-label=${`Machine: ${t}. Open machine selection.`} @click=${()=>{this.onOpenSection?.(`machines`)}}>
|
|
5021
5145
|
<span class="context-kind">Machine</span>
|
|
5022
5146
|
<span class="context-value">${t}</span>
|
|
5023
5147
|
</button>
|
|
5024
5148
|
</li>
|
|
5025
5149
|
`:null}
|
|
5026
5150
|
<li class="context-item">
|
|
5027
|
-
<button type="button" class=${this.project===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5151
|
+
<button type="button" class=${this.project===void 0?`context-chip empty`:`context-chip`} title=${_O(this.project)} aria-label=${`Project: ${n}. Open project selection.`} @click=${()=>{this.onOpenSection?.(`projects`)}}>
|
|
5028
5152
|
<span class="context-kind">Project</span>
|
|
5029
5153
|
<span class="context-value">${n}</span>
|
|
5030
5154
|
</button>
|
|
5031
5155
|
</li>
|
|
5032
5156
|
<li class="context-item">
|
|
5033
|
-
<button type="button" class=${this.workspace===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5157
|
+
<button type="button" class=${this.workspace===void 0?`context-chip empty`:`context-chip`} title=${yO(this.workspace)} aria-label=${`Workspace: ${r}. Open workspace selection.`} @click=${()=>{this.onOpenSection?.(`workspaces`)}}>
|
|
5034
5158
|
<span class="context-kind">Workspace</span>
|
|
5035
5159
|
<span class="context-value">${r}</span>
|
|
5036
5160
|
</button>
|
|
5037
5161
|
</li>
|
|
5038
5162
|
<li class="context-item">
|
|
5039
|
-
<button type="button" class=${this.session===void 0?`context-chip empty`:`context-chip`} title=${
|
|
5163
|
+
<button type="button" class=${this.session===void 0?`context-chip empty`:`context-chip`} title=${xO(this.session)} aria-label=${`Session: ${i}. Open session selection.`} @click=${()=>{this.onOpenSection?.(`sessions`)}}>
|
|
5040
5164
|
<span class="context-kind">Session</span>
|
|
5041
5165
|
<span class="context-value">${i}</span>
|
|
5042
5166
|
</button>
|
|
@@ -5076,7 +5200,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5076
5200
|
.context-kind { display: none; }
|
|
5077
5201
|
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
5078
5202
|
button { cursor: pointer; }
|
|
5079
|
-
`}};B([x({attribute:!1})],
|
|
5203
|
+
`}};B([x({attribute:!1})],fO.prototype,`machines`,void 0),B([x({attribute:!1})],fO.prototype,`machine`,void 0),B([x({attribute:!1})],fO.prototype,`project`,void 0),B([x({attribute:!1})],fO.prototype,`workspace`,void 0),B([x({attribute:!1})],fO.prototype,`session`,void 0),B([x({attribute:!1})],fO.prototype,`refreshControl`,void 0),B([x({attribute:!1})],fO.prototype,`onOpenSection`,void 0),B([x({attribute:!1})],fO.prototype,`onShowActions`,void 0),B([C(`.context-items`)],fO.prototype,`contextItems`,void 0),B([S()],fO.prototype,`canScrollLeft`,void 0),B([S()],fO.prototype,`canScrollRight`,void 0),fO=B([b(`app-context-bar`)],fO);function pO(e){return e.length>1}function mO(e){return e===void 0?`No machine`:`${e.name}${e.kind===`remote`?` · remote`:``}`}function hO(e){return e===void 0?`No machine selected`:e.baseUrl??e.name}function gO(e){return e?.name??`No project`}function _O(e){return e===void 0?`No project selected`:`${e.name} — ${e.path}`}function vO(e){return e===void 0?`No workspace`:`${e.label}${e.isMain?` · main`:``} · ${e.path}`}function yO(e){return e===void 0?`No workspace selected`:`${e.label}${e.isMain?` · main`:``} — ${e.path}`}function bO(e){let t=e?.name?.trim(),n=e?.firstMessage.trim();return t!==void 0&&t!==``?t:n!==void 0&&n!==``?n:e===void 0?`No session`:J_(e.id)}function xO(e){return e===void 0?`No session selected`:e.path}var SO=class extends y{constructor(...e){super(...e),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(){let e=this.fallbackLabels();return g`
|
|
5080
5204
|
<div class=${this.frameClass()}>
|
|
5081
5205
|
<div class="mobile-tabs" @scroll=${this.onMobileTabsScroll}>
|
|
5082
5206
|
${this.tabs.map(t=>{let n=this.selectedView===t.id;return g`
|
|
@@ -5115,12 +5239,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5115
5239
|
.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; }
|
|
5116
5240
|
.tab-badge { min-width: 13px; padding: 0 4px; font-size: 10px; line-height: 13px; }
|
|
5117
5241
|
}
|
|
5118
|
-
`}};B([x({attribute:!1})],
|
|
5242
|
+
`}};B([x({attribute:!1})],SO.prototype,`tabs`,void 0),B([x({attribute:!1})],SO.prototype,`selectedView`,void 0),B([x({attribute:!1})],SO.prototype,`onSelect`,void 0),B([C(`.mobile-tabs`)],SO.prototype,`mobileTabs`,void 0),B([S()],SO.prototype,`canScrollLeft`,void 0),B([S()],SO.prototype,`canScrollRight`,void 0),SO=B([b(`app-mobile-main-tabs`)],SO);var CO=class extends y{constructor(...e){super(...e),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(e=>e.id===this.openActionsMachineId)&&(this.openActionsMachineId=void 0)}async focusSelectedOrFirst(){let e=this.switcherButton();return e!==null&&await this.openMenuAndFocusOption(e)}render(){let e=this.selectedMachine();if(e===void 0)return null;let t=wO(e,this.statuses),n=e.name;return g`
|
|
5119
5243
|
<div class="machine-switcher">
|
|
5120
5244
|
<button
|
|
5121
5245
|
type="button"
|
|
5122
5246
|
class="machine-switcher-button"
|
|
5123
|
-
title=${
|
|
5247
|
+
title=${EO(e)}
|
|
5124
5248
|
aria-label=${this.machineSwitcherAriaLabel(e)}
|
|
5125
5249
|
aria-expanded=${String(this.open)}
|
|
5126
5250
|
@click=${e=>{this.toggleMenu(e.currentTarget)}}
|
|
@@ -5131,7 +5255,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5131
5255
|
<span class="machine-switcher-kicker">Machine</span>
|
|
5132
5256
|
<span class="machine-switcher-label">${n}</span>
|
|
5133
5257
|
</span>
|
|
5134
|
-
<span class=${`machine-status ${t}`}>${
|
|
5258
|
+
<span class=${`machine-status ${t}`}>${TO(t)}</span>
|
|
5135
5259
|
<span class="machine-chevron" aria-hidden="true">▾</span>
|
|
5136
5260
|
</button>
|
|
5137
5261
|
${this.open?g`
|
|
@@ -5140,18 +5264,18 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5140
5264
|
</div>
|
|
5141
5265
|
`:null}
|
|
5142
5266
|
</div>
|
|
5143
|
-
`}renderMachineOption(e){let t=this.selected?.id===e.id,n=
|
|
5267
|
+
`}renderMachineOption(e){let t=this.selected?.id===e.id,n=wO(e,this.statuses),r=y_(e)&&this.onRemove!==void 0,i=this.openActionsMachineId===e.id;return g`
|
|
5144
5268
|
<div class=${`machine-option ${t?`selected`:``} ${r?``:`no-actions`}`}>
|
|
5145
5269
|
<button
|
|
5146
5270
|
type="button"
|
|
5147
5271
|
class="machine-option-main"
|
|
5148
|
-
title=${
|
|
5272
|
+
title=${EO(e)}
|
|
5149
5273
|
data-machine-id=${e.id}
|
|
5150
5274
|
@click=${()=>{this.select(e)}}
|
|
5151
5275
|
@keydown=${e=>{this.handleMachineOptionKeydown(e)}}
|
|
5152
5276
|
>
|
|
5153
5277
|
<span class="machine-option-name">${this.renderActivity(e)}<span>${e.name}</span></span>
|
|
5154
|
-
<small>${e.kind===`local`?`Local Pi WebUI`:e.baseUrl??`Remote Pi WebUI`} · ${
|
|
5278
|
+
<small>${e.kind===`local`?`Local Pi WebUI`:e.baseUrl??`Remote Pi WebUI`} · ${TO(n)}</small>
|
|
5155
5279
|
</button>
|
|
5156
5280
|
${r?g`
|
|
5157
5281
|
<div class="machine-option-actions">
|
|
@@ -5171,7 +5295,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5171
5295
|
</div>
|
|
5172
5296
|
`:null}
|
|
5173
5297
|
</div>
|
|
5174
|
-
`}renderActivity(e){let t=
|
|
5298
|
+
`}renderActivity(e){let t=wO(e,this.statuses);if(t===`offline`||t===`error`)return;let n=Fs(this.activities[e.id]);return r_(n,n===`terminal`?`Machine terminal active`:`Machine active`)}selectedMachine(){return this.selected??this.machines.find(e=>e.id===`local`)??this.machines[0]}machineSwitcherAriaLabel(e){return`Machine: ${e.name}. Switch machine.`}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=DO(e),this.open=!this.open,this.openActionsMachineId=void 0}focusSwitcherButton(){let e=this.switcherButton();return e===null?!1:(e.focus(),!0)}async openMenuAndFocusOption(e){return this.menuStyle=DO(e),this.open=!0,this.openActionsMachineId=void 0,await this.updateComplete,this.focusSelectedMachineOption()}focusSelectedMachineOption(){let e=this.renderRoot.querySelector(`.machine-option.selected .machine-option-main`),t=this.machineOptionButtons()[0],n=e??t;return n===void 0?!1:(n.focus(),n.scrollIntoView({block:`nearest`}),!0)}focusRelativeMachineOption(e,t,n){n.preventDefault(),n.stopPropagation();let r=this.machineOptionButtons();if(r.length===0||!(e instanceof HTMLElement))return;let i=r.indexOf(e);i<0||this.focusMachineOptionAt(i+t)}focusIndexedMachineOption(e,t){t.preventDefault(),t.stopPropagation(),this.focusMachineOptionAt(e<0?this.machineOptionButtons().length-1:e)}focusMachineOptionAt(e){let t=this.machineOptionButtons(),n=t[Math.min(Math.max(e,0),t.length-1)];n?.focus(),n?.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=$g(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)}static{this.styles=h`
|
|
5175
5299
|
:host { min-width: 0; display: block; }
|
|
5176
5300
|
.machine-switcher { min-width: 0; }
|
|
5177
5301
|
.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; }
|
|
@@ -5204,10 +5328,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5204
5328
|
.machine-option-actions-panel button:hover, .machine-option-actions-panel button:focus-visible { background: var(--pi-selection-bg); }
|
|
5205
5329
|
.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); }
|
|
5206
5330
|
@keyframes pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
|
|
5207
|
-
`}};B([x({attribute:!1})],
|
|
5331
|
+
`}};B([x({attribute:!1})],CO.prototype,`machines`,void 0),B([x({attribute:!1})],CO.prototype,`selected`,void 0),B([x({attribute:!1})],CO.prototype,`statuses`,void 0),B([x({attribute:!1})],CO.prototype,`activities`,void 0),B([x({attribute:!1})],CO.prototype,`onSelect`,void 0),B([x({attribute:!1})],CO.prototype,`onRemove`,void 0),B([x({attribute:!1})],CO.prototype,`onFocusNextSection`,void 0),B([x({attribute:!1})],CO.prototype,`onCancelKeyboardNavigation`,void 0),B([S()],CO.prototype,`open`,void 0),B([S()],CO.prototype,`menuStyle`,void 0),B([S()],CO.prototype,`openActionsMachineId`,void 0),B([S()],CO.prototype,`actionMenuStyle`,void 0),CO=B([b(`machine-switcher`)],CO);function wO(e,t){return t[e.id]?.status??e.status??`unknown`}function TO(e){return e===`online`?`online`:e===`offline`?`offline`:e===`error`?`error`:`unknown`}function EO(e){return e.baseUrl??e.name}function DO(e){if(typeof HTMLElement>`u`||typeof window>`u`||!(e instanceof HTMLElement))return``;let t=e.getBoundingClientRect(),n=Math.min(280,Math.max(0,window.innerWidth-16)),r=Math.min(Math.max(8,t.left),Math.max(8,window.innerWidth-8-n)),i=Math.max(0,window.innerHeight-t.bottom-8);return[`top: ${OO(t.bottom)};`,`left: ${OO(r)};`,`width: ${OO(n)};`,`max-height: ${OO(i)};`].join(` `)}function OO(e){return`${String(Math.round(e))}px`}var kO=[{id:`models`,label:`Models`},{id:`skills`,label:`Skills`},{id:`plugins`,label:`Plugins`}],Q=class extends y{constructor(...e){super(...e),this.machines=[],this.machineStatuses={},this.machineActivities={},this.projects=[],this.workspaces=[],this.sessions=[],this.projectSessions=[],this.workspaceActivities={},this.sessionActivities={},this.sessionStatuses={},this.sendingPrompts={},this.unreadSessionIds=new Set,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.startingSessionCount=0,this.canStartSession=!1,this.canDeleteArchivedSessions=!1,this.canReloadSessions=!1,this.canCleanupSessions=!1,this.authoritativeSessionPersistence=!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.skillsEnabled=!1,this.pluginsEnabled=!1}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(){let e=this.version;return g`
|
|
5208
5332
|
<header>
|
|
5209
5333
|
<strong class="brand" aria-label=${e===void 0?`Pi WebUI`:`Pi WebUI version ${e}`}><span class="brand-symbol" aria-hidden="true">π</span><span>WebUI</span>${e===void 0?null:g`<span class="brand-version">v${e}</span>`}</strong>
|
|
5210
|
-
${
|
|
5334
|
+
${NO(this.machines)?g`
|
|
5211
5335
|
<machine-switcher
|
|
5212
5336
|
.machines=${this.machines}
|
|
5213
5337
|
.selected=${this.selectedMachine}
|
|
@@ -5224,7 +5348,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5224
5348
|
<button title="Show Actions" aria-label="Show Actions" @click=${()=>{this.onShowActions?.()}}>Actions</button>
|
|
5225
5349
|
</div>
|
|
5226
5350
|
</header>
|
|
5227
|
-
${this.compact&&
|
|
5351
|
+
${this.compact&&NO(this.machines)?g`
|
|
5228
5352
|
<machine-list
|
|
5229
5353
|
.machines=${this.machines}
|
|
5230
5354
|
.selected=${this.selectedMachine}
|
|
@@ -5248,6 +5372,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5248
5372
|
.collapsed=${this.projectsCollapsed}
|
|
5249
5373
|
.onToggleCollapsed=${()=>{this.onToggleProjects?.()}}
|
|
5250
5374
|
.onAdd=${()=>{this.onAddProject?.()}}
|
|
5375
|
+
.onOpenExpanded=${e=>this.onOpenProjectBrowser?.(e)}
|
|
5251
5376
|
.onSelect=${e=>this.onSelectProject?.(e)}
|
|
5252
5377
|
.onClose=${e=>this.onCloseProject?.(e)}
|
|
5253
5378
|
.onFocusPreviousSection=${()=>{this.focusPreviousFrom(`projects`)}}
|
|
@@ -5312,9 +5437,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5312
5437
|
.onCancelKeyboardNavigation=${()=>{this.cancelKeyboardNavigation()}}
|
|
5313
5438
|
></session-list>
|
|
5314
5439
|
<footer class="resource-underbar" aria-label="Resources">
|
|
5315
|
-
${
|
|
5440
|
+
${kO.map(e=>AO(e,e.id===`models`?()=>{this.onOpenModels?.()}:e.id===`skills`?()=>{this.onOpenSkills?.()}:()=>{this.onOpenPlugins?.()},this.skillsEnabled,this.pluginsEnabled))}
|
|
5316
5441
|
</footer>
|
|
5317
|
-
`}async focusNavigableSection(e){return e!==void 0&&await e.focusSelectedOrFirst()}focusPreviousFrom(e){let t=
|
|
5442
|
+
`}async focusNavigableSection(e){return e!==void 0&&await e.focusSelectedOrFirst()}focusPreviousFrom(e){let t=PO(e,this.machines);t!==void 0&&this.onFocusNavigationTarget?.(t)}focusNextFrom(e){this.onFocusNavigationTarget?.(FO(e,this.machines))}cancelKeyboardNavigation(){this.onCancelKeyboardNavigation?.()}static{this.styles=h`
|
|
5318
5443
|
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
5319
5444
|
:host([compact]) { flex: 1 1 auto; }
|
|
5320
5445
|
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); }
|
|
@@ -5346,12 +5471,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5346
5471
|
:host([compact]) workspace-list[collapsed],
|
|
5347
5472
|
:host([compact]) session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
5348
5473
|
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
5349
|
-
`}};B([x({attribute:!1})],Q.prototype,`machines`,void 0),B([x({attribute:!1})],Q.prototype,`selectedMachine`,void 0),B([x({attribute:!1})],Q.prototype,`machineStatuses`,void 0),B([x({attribute:!1})],Q.prototype,`machineActivities`,void 0),B([x({attribute:!1})],Q.prototype,`projects`,void 0),B([x({attribute:!1})],Q.prototype,`selectedProject`,void 0),B([x({attribute:!1})],Q.prototype,`workspaces`,void 0),B([x({attribute:!1})],Q.prototype,`selectedWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`sessions`,void 0),B([x({attribute:!1})],Q.prototype,`projectSessions`,void 0),B([x({attribute:!1})],Q.prototype,`selectedSession`,void 0),B([x({attribute:!1})],Q.prototype,`workspaceActivities`,void 0),B([x({attribute:!1})],Q.prototype,`sessionActivities`,void 0),B([x({attribute:!1})],Q.prototype,`sessionStatuses`,void 0),B([x({attribute:!1})],Q.prototype,`sendingPrompts`,void 0),B([x({attribute:!1})],Q.prototype,`unreadSessionIds`,void 0),B([x({attribute:!1})],Q.prototype,`workspacesByProjectId`,void 0),B([x({attribute:!1})],Q.prototype,`deletingWorkspaceIds`,void 0),B([x({attribute:!1})],Q.prototype,`workspaceLabelItems`,void 0),B([x({type:String})],Q.prototype,`version`,void 0),B([x({attribute:!1})],Q.prototype,`refreshControl`,void 0),B([x({type:Boolean,reflect:!0})],Q.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],Q.prototype,`compact`,void 0),B([x({type:Boolean})],Q.prototype,`machinesCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`projectsCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`workspacesCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`sessionsCollapsed`,void 0),B([x({type:Number})],Q.prototype,`startingSessionCount`,void 0),B([x({type:Boolean})],Q.prototype,`canStartSession`,void 0),B([x({type:Boolean})],Q.prototype,`canDeleteArchivedSessions`,void 0),B([x({type:Boolean})],Q.prototype,`canReloadSessions`,void 0),B([x({type:Boolean})],Q.prototype,`canCleanupSessions`,void 0),B([x({type:Boolean})],Q.prototype,`authoritativeSessionPersistence`,void 0),B([x({type:String})],Q.prototype,`archivedDeleteUnavailableMessage`,void 0),B([x({type:String})],Q.prototype,`cleanupUnavailableMessage`,void 0),B([x({attribute:!1})],Q.prototype,`onShowActions`,void 0),B([x({type:Boolean})],Q.prototype,`skillsEnabled`,void 0),B([x({type:Boolean})],Q.prototype,`pluginsEnabled`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenModels`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenSkills`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenPlugins`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleMachines`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleProjects`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleWorkspaces`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onAddProject`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectProject`,void 0),B([x({attribute:!1})],Q.prototype,`onCloseProject`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`onStartSession`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectSession`,void 0),B([x({attribute:!1})],Q.prototype,`onRenameSessionStart`,void 0),B([x({attribute:!1})],Q.prototype,`onRenameSession`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSession`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSessionWithDescendants`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onRestoreSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteCachedNewSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteArchivedSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteArchivedSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onDetachParentSession`,void 0),B([x({attribute:!1})],Q.prototype,`onReloadSession`,void 0),B([x({attribute:!1})],Q.prototype,`onPinSession`,void 0),B([x({attribute:!1})],Q.prototype,`onUnpinSession`,void 0),B([x({attribute:!1})],Q.prototype,`onCleanupSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onArchivedCollapsed`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectMachine`,void 0),B([x({attribute:!1})],Q.prototype,`onRemoveMachine`,void 0),B([x({attribute:!1})],Q.prototype,`onFocusNavigationTarget`,void 0),B([x({attribute:!1})],Q.prototype,`onCancelKeyboardNavigation`,void 0),B([C(`machine-list`)],Q.prototype,`machineList`,void 0),B([C(`machine-switcher`)],Q.prototype,`machineSwitcher`,void 0),B([C(`project-list`)],Q.prototype,`projectList`,void 0),B([C(`workspace-list`)],Q.prototype,`workspaceList`,void 0),B([C(`session-list`)],Q.prototype,`sessionList`,void 0),Q=B([b(`app-navigation-panel`)],Q);function
|
|
5350
|
-
<button type="button" ?disabled=${!
|
|
5351
|
-
${
|
|
5474
|
+
`}};B([x({attribute:!1})],Q.prototype,`machines`,void 0),B([x({attribute:!1})],Q.prototype,`selectedMachine`,void 0),B([x({attribute:!1})],Q.prototype,`machineStatuses`,void 0),B([x({attribute:!1})],Q.prototype,`machineActivities`,void 0),B([x({attribute:!1})],Q.prototype,`projects`,void 0),B([x({attribute:!1})],Q.prototype,`selectedProject`,void 0),B([x({attribute:!1})],Q.prototype,`workspaces`,void 0),B([x({attribute:!1})],Q.prototype,`selectedWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`sessions`,void 0),B([x({attribute:!1})],Q.prototype,`projectSessions`,void 0),B([x({attribute:!1})],Q.prototype,`selectedSession`,void 0),B([x({attribute:!1})],Q.prototype,`workspaceActivities`,void 0),B([x({attribute:!1})],Q.prototype,`sessionActivities`,void 0),B([x({attribute:!1})],Q.prototype,`sessionStatuses`,void 0),B([x({attribute:!1})],Q.prototype,`sendingPrompts`,void 0),B([x({attribute:!1})],Q.prototype,`unreadSessionIds`,void 0),B([x({attribute:!1})],Q.prototype,`workspacesByProjectId`,void 0),B([x({attribute:!1})],Q.prototype,`deletingWorkspaceIds`,void 0),B([x({attribute:!1})],Q.prototype,`workspaceLabelItems`,void 0),B([x({type:String})],Q.prototype,`version`,void 0),B([x({attribute:!1})],Q.prototype,`refreshControl`,void 0),B([x({type:Boolean,reflect:!0})],Q.prototype,`collapsible`,void 0),B([x({type:Boolean,reflect:!0})],Q.prototype,`compact`,void 0),B([x({type:Boolean})],Q.prototype,`machinesCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`projectsCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`workspacesCollapsed`,void 0),B([x({type:Boolean})],Q.prototype,`sessionsCollapsed`,void 0),B([x({type:Number})],Q.prototype,`startingSessionCount`,void 0),B([x({type:Boolean})],Q.prototype,`canStartSession`,void 0),B([x({type:Boolean})],Q.prototype,`canDeleteArchivedSessions`,void 0),B([x({type:Boolean})],Q.prototype,`canReloadSessions`,void 0),B([x({type:Boolean})],Q.prototype,`canCleanupSessions`,void 0),B([x({type:Boolean})],Q.prototype,`authoritativeSessionPersistence`,void 0),B([x({type:String})],Q.prototype,`archivedDeleteUnavailableMessage`,void 0),B([x({type:String})],Q.prototype,`cleanupUnavailableMessage`,void 0),B([x({attribute:!1})],Q.prototype,`onShowActions`,void 0),B([x({type:Boolean})],Q.prototype,`skillsEnabled`,void 0),B([x({type:Boolean})],Q.prototype,`pluginsEnabled`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenModels`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenSkills`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenPlugins`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleMachines`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleProjects`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleWorkspaces`,void 0),B([x({attribute:!1})],Q.prototype,`onToggleSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onAddProject`,void 0),B([x({attribute:!1})],Q.prototype,`onOpenProjectBrowser`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectProject`,void 0),B([x({attribute:!1})],Q.prototype,`onCloseProject`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteWorkspace`,void 0),B([x({attribute:!1})],Q.prototype,`onStartSession`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectSession`,void 0),B([x({attribute:!1})],Q.prototype,`onRenameSessionStart`,void 0),B([x({attribute:!1})],Q.prototype,`onRenameSession`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSession`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSessionWithDescendants`,void 0),B([x({attribute:!1})],Q.prototype,`onArchiveSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onRestoreSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteCachedNewSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteArchivedSession`,void 0),B([x({attribute:!1})],Q.prototype,`onDeleteArchivedSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onDetachParentSession`,void 0),B([x({attribute:!1})],Q.prototype,`onReloadSession`,void 0),B([x({attribute:!1})],Q.prototype,`onPinSession`,void 0),B([x({attribute:!1})],Q.prototype,`onUnpinSession`,void 0),B([x({attribute:!1})],Q.prototype,`onCleanupSessions`,void 0),B([x({attribute:!1})],Q.prototype,`onArchivedCollapsed`,void 0),B([x({attribute:!1})],Q.prototype,`onSelectMachine`,void 0),B([x({attribute:!1})],Q.prototype,`onRemoveMachine`,void 0),B([x({attribute:!1})],Q.prototype,`onFocusNavigationTarget`,void 0),B([x({attribute:!1})],Q.prototype,`onCancelKeyboardNavigation`,void 0),B([C(`machine-list`)],Q.prototype,`machineList`,void 0),B([C(`machine-switcher`)],Q.prototype,`machineSwitcher`,void 0),B([C(`project-list`)],Q.prototype,`projectList`,void 0),B([C(`workspace-list`)],Q.prototype,`workspaceList`,void 0),B([C(`session-list`)],Q.prototype,`sessionList`,void 0),Q=B([b(`app-navigation-panel`)],Q);function AO(e,t,n,r){return g`
|
|
5475
|
+
<button type="button" ?disabled=${!jO(e.id,n,r)} title=${e.label} aria-label=${e.label} @click=${t}>
|
|
5476
|
+
${MO(e.id)}
|
|
5352
5477
|
<span>${e.label}</span>
|
|
5353
5478
|
</button>
|
|
5354
|
-
`}function
|
|
5479
|
+
`}function jO(e,t=!1,n=t){return e===`models`||e===`skills`&&t||e===`plugins`&&n}function MO(e){switch(e){case`models`:return _`
|
|
5355
5480
|
<svg class="resource-underbar-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
5356
5481
|
<rect x="4" y="4" width="16" height="16" rx="2"></rect>
|
|
5357
5482
|
<rect x="9" y="9" width="6" height="6"></rect>
|
|
@@ -5369,7 +5494,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5369
5494
|
<path d="M6 13V8a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v5a6 6 0 0 1-12 0Z"></path>
|
|
5370
5495
|
<path d="M12 19v3"></path>
|
|
5371
5496
|
</svg>
|
|
5372
|
-
`}}function
|
|
5497
|
+
`}}function NO(e){return e.length>1}function PO(e,t){let n=IO(t);return n[n.indexOf(e)-1]}function FO(e,t){let n=IO(t);return n[n.indexOf(e)+1]??`chat`}function IO(e){return Fh.filter(t=>t!==`machines`||NO(e))}var LO=new Set([`ArrowLeft`,`ArrowRight`,`Home`,`End`]),RO=420,zO=4,BO=class extends y{constructor(...e){super(...e),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(){let e=this.collapsed?this.expandLabel:this.collapseLabel;return g`
|
|
5373
5498
|
${this.renderResizeHandle()}
|
|
5374
5499
|
<button
|
|
5375
5500
|
type="button"
|
|
@@ -5399,7 +5524,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5399
5524
|
@dblclick=${e=>{this.onResizeDoubleClick(e)}}
|
|
5400
5525
|
@keydown=${e=>{this.onResizeKeyDown(e)}}
|
|
5401
5526
|
></div>
|
|
5402
|
-
`}resizeAriaValueNow(){return this.panelWidth===void 0?v:String(Math.round(this.panelWidth))}renderIcon(){return g`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${this.iconDirection()===`left`?`M15 18l-6-6 6-6`:`M9 18l6-6-6-6`}/></svg>`}iconDirection(){return this.side===`navigation`?this.collapsed?`right`:`left`:this.collapsed?`left`:`right`}onResizePointerDown(e){if(!this.resizable||e.button!==0)return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=this.resizeStartWidth();n!==void 0&&(e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),this.activeResize={pointerId:e.pointerId,startClientX:e.clientX,startWidth:n,handle:t,moved:!1},this.toggleAttribute(`resizing`,!0))}onResizePointerMove(e){let t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),!(Math.abs(e.clientX-t.startClientX)<=
|
|
5527
|
+
`}resizeAriaValueNow(){return this.panelWidth===void 0?v:String(Math.round(this.panelWidth))}renderIcon(){return g`<svg class="edge-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${this.iconDirection()===`left`?`M15 18l-6-6 6-6`:`M9 18l6-6-6-6`}/></svg>`}iconDirection(){return this.side===`navigation`?this.collapsed?`right`:`left`:this.collapsed?`left`:`right`}onResizePointerDown(e){if(!this.resizable||e.button!==0)return;let t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=this.resizeStartWidth();n!==void 0&&(e.preventDefault(),e.stopPropagation(),t.setPointerCapture(e.pointerId),this.activeResize={pointerId:e.pointerId,startClientX:e.clientX,startWidth:n,handle:t,moved:!1},this.toggleAttribute(`resizing`,!0))}onResizePointerMove(e){let t=this.activeResize;t?.pointerId===e.pointerId&&(e.preventDefault(),!(Math.abs(e.clientX-t.startClientX)<=zO)&&(t.moved=!0,this.commitPanelWidth($h(this.side,t.startWidth,t.startClientX,e.clientX,this.resizeConstraints()))))}onResizePointerUp(e){let 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||!LO.has(e.key))return;let t=this.resizeStartWidth();if(t===void 0)return;let n=eg(this.side,t,e.key,{largeStep:e.shiftKey,constraints:this.resizeConstraints()});n!==void 0&&(e.preventDefault(),e.stopPropagation(),this.commitPanelWidth(n),this.onResizeEnd?.())}registerTapForReset(){let e=Date.now();if(e-this.lastTapAt<=RO){this.lastTapAt=0,this.resetPanelSize();return}this.lastTapAt=e}resetPanelSize(){this.finishActiveResize(),this.onReset?.()}resizeStartWidth(){let e=this.onResizeStart?.()??this.panelWidth;if(e!==void 0)return tg(this.side,e,this.resizeConstraints())}commitPanelWidth(e){this.onResize?.(tg(this.side,e,this.resizeConstraints()))}finishActiveResize(){let 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(){let e=Zh(this.side);return{...e,minWidth:this.minWidth??e.minWidth,maxWidth:this.maxWidth??e.maxWidth}}static{this.styles=h`
|
|
5403
5528
|
: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; }
|
|
5404
5529
|
:host([side="navigation"]) { grid-column: 2; }
|
|
5405
5530
|
:host([side="workspace"]) { grid-column: 4; }
|
|
@@ -5418,7 +5543,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5418
5543
|
@media (max-width: 760px) {
|
|
5419
5544
|
:host([side="navigation"]) { display: none; }
|
|
5420
5545
|
}
|
|
5421
|
-
`}};B([x({reflect:!0})],
|
|
5546
|
+
`}};B([x({reflect:!0})],BO.prototype,`side`,void 0),B([x({type:Boolean,reflect:!0})],BO.prototype,`collapsed`,void 0),B([x({type:Boolean})],BO.prototype,`resizable`,void 0),B([x({type:Number})],BO.prototype,`panelWidth`,void 0),B([x({type:Number})],BO.prototype,`minWidth`,void 0),B([x({type:Number})],BO.prototype,`maxWidth`,void 0),B([x()],BO.prototype,`controls`,void 0),B([x()],BO.prototype,`resizeLabel`,void 0),B([x()],BO.prototype,`expandLabel`,void 0),B([x()],BO.prototype,`collapseLabel`,void 0),B([x({attribute:!1})],BO.prototype,`onToggle`,void 0),B([x({attribute:!1})],BO.prototype,`onResizeStart`,void 0),B([x({attribute:!1})],BO.prototype,`onResize`,void 0),B([x({attribute:!1})],BO.prototype,`onResizeEnd`,void 0),B([x({attribute:!1})],BO.prototype,`onReset`,void 0),BO=B([b(`app-panel-edge-control`)],BO);var VO=class extends y{constructor(...e){super(...e),this.onReloadClick=e=>{e.stopPropagation(),this.onReload?.()}}render(){let e=`Full page reload`;return g`
|
|
5422
5547
|
<button
|
|
5423
5548
|
class="app-refresh-button"
|
|
5424
5549
|
title=${e}
|
|
@@ -5437,7 +5562,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5437
5562
|
:host, :host * { -webkit-user-select: none; user-select: none; }
|
|
5438
5563
|
.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; }
|
|
5439
5564
|
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
5440
|
-
`}};B([x({attribute:!1})],
|
|
5565
|
+
`}};B([x({attribute:!1})],VO.prototype,`onReload`,void 0),VO=B([b(`app-refresh-control`)],VO);var HO=[`terminal`,`git-update-manager`,`theme`,`system-prompt`,`history`,`info`],UO=`file-manager`,WO=`browser`,GO=[...HO],KO=new Set(HO),qO=`pi-webui:activity-rail-order`;function JO(){return typeof localStorage>`u`?void 0:localStorage}function YO(e){return KO.has(e)}function XO(e){if(!Array.isArray(e))return;let t=[],n=new Set;for(let r of e){if(typeof r!=`string`)return;let e=r===UO?`git-update-manager`:r;if(e!==WO){if(!YO(e)||n.has(e))return;n.add(e),t.push(e)}}if(t.length===HO.length)return t;let r=[...t];if(!n.has(`git-update-manager`)){let e=r.indexOf(`terminal`);r.splice(e+1,0,`git-update-manager`)}return n.has(`info`)||r.push(`info`),r.length===HO.length?r:void 0}function ZO(){try{let e=JO();if(e===void 0)return;let t=e.getItem(qO);return t===null?void 0:XO(JSON.parse(t))}catch{return}}function QO(e){try{let t=JO();if(t===void 0)return;t.setItem(qO,JSON.stringify(e))}catch{}}var $O=`(min-width: 1181px)`,ek=[`terminal`,`git-update-manager`,`theme`,`system-prompt`,`history`,`info`];function tk(e){return ek.includes(e)}var nk=class extends y{constructor(){super(),this.terminalCount=0,this.gitUpdateManagerCount=0,this.systemPromptEnabled=!1,this.historyEnabled=!1,this.railOrder=[...GO],this.onDesktopMediaChange=()=>{},this.openTerminal=()=>{this.onOpenTerminal?.()},this.openGitUpdateManager=()=>{this.onOpenGitUpdateManager?.()},this.openTheme=()=>{this.onOpenTheme?.()},this.openSystemPrompt=()=>{this.onOpenSystemPrompt?.()},this.openHistory=()=>{this.onOpenHistory?.()},this.openInfo=()=>{this.onOpenInfo?.()},this.openSettings=()=>{this.onOpenSettings?.()},this.onDragStart=(e,t)=>{this.dragItem=e,t.dataTransfer!==null&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e)),requestAnimationFrame(()=>{this.renderRoot.querySelector(`[data-rail-item="${e}"]`)?.classList.add(`dragging`)})},this.onDragEnd=e=>{this.dragItem=void 0,this.renderRoot.querySelector(`[data-rail-item="${e}"]`)?.classList.remove(`dragging`),this.renderRoot.querySelectorAll(`.drag-over`).forEach(e=>{e.classList.remove(`drag-over`)})},this.onRailDragOver=e=>{if(e.preventDefault(),e.dataTransfer!==null&&(e.dataTransfer.dropEffect=`move`),this.dragItem===void 0)return;let t=this.resolveDragTarget(e.target);this.renderRoot.querySelectorAll(`.drag-over`).forEach(e=>{e.classList.remove(`drag-over`)}),t!==null&&t.dataset.railItem!==this.dragItem&&t.classList.add(`drag-over`)},this.onRailDrop=e=>{if(e.preventDefault(),this.renderRoot.querySelectorAll(`.drag-over`).forEach(e=>{e.classList.remove(`drag-over`)}),this.dragItem===void 0)return;let t=this.resolveDragTarget(e.target);if(t===null||t.dataset.railItem===this.dragItem){this.dragItem=void 0;return}let n=t.dataset.railItem;if(n===void 0||!tk(n)){this.dragItem=void 0;return}let r=[...this.railOrder],i=r.indexOf(this.dragItem),a=r.indexOf(n);if(i===-1||a===-1){this.dragItem=void 0;return}r.splice(i,1),r.splice(a,0,this.dragItem),this.railOrder=r,this.onRailOrderChange?.(r),this.dragItem=void 0},typeof window<`u`&&`matchMedia`in window&&(this.desktopMedia=window.matchMedia($O))}connectedCallback(){super.connectedCallback(),this.desktopMedia?.addEventListener(`change`,this.onDesktopMediaChange)}disconnectedCallback(){super.disconnectedCallback(),this.desktopMedia?.removeEventListener(`change`,this.onDesktopMediaChange)}resolveDragTarget(e){if(e===null||!(e instanceof HTMLElement))return null;let t=e.closest(`[data-rail-item]`);return t instanceof HTMLElement?t:null}dndProps(e){return{draggable:`true`,"data-rail-item":e}}renderReorderableButton(e){switch(e){case`terminal`:return this.renderTerminalButton();case`git-update-manager`:return this.renderGitUpdateManagerButton();case`theme`:return this.renderThemeButton();case`system-prompt`:return this.renderSystemPromptButton();case`history`:return this.renderHistoryButton();case`info`:return this.renderInfoButton()}}renderTerminalButton(){let e=this.dndProps(`terminal`),t=this.terminalCount>0?this.terminalCount:void 0,n=t===void 0?``:`${String(t)} active terminal${t===1?``:`s`}`;return g`
|
|
5441
5566
|
<button
|
|
5442
5567
|
type="button"
|
|
5443
5568
|
class="icon-button terminal-button"
|
|
@@ -5458,27 +5583,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5458
5583
|
</svg>
|
|
5459
5584
|
${t===void 0?v:g`<span class="rail-badge" aria-hidden="true">${t}</span>`}
|
|
5460
5585
|
</button>
|
|
5461
|
-
`}renderBrowserButton(){let e=this.dndProps(`browser`);return g`
|
|
5462
|
-
<button
|
|
5463
|
-
type="button"
|
|
5464
|
-
class="icon-button browser-button"
|
|
5465
|
-
title="Browser"
|
|
5466
|
-
aria-label="Open browser"
|
|
5467
|
-
@click=${this.openBrowser}
|
|
5468
|
-
draggable=${e.draggable}
|
|
5469
|
-
data-rail-item=${e[`data-rail-item`]}
|
|
5470
|
-
@dragstart=${e=>{this.onDragStart(`browser`,e)}}
|
|
5471
|
-
@dragend=${()=>{this.onDragEnd(`browser`)}}
|
|
5472
|
-
>
|
|
5473
|
-
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
5474
|
-
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
5475
|
-
aria-hidden="true" focusable="false">
|
|
5476
|
-
<circle cx="12" cy="12" r="9"/>
|
|
5477
|
-
<path d="M3 12h18"/>
|
|
5478
|
-
<path d="M12 3a14 14 0 0 1 0 18"/>
|
|
5479
|
-
<path d="M12 3a14 14 0 0 0 0 18"/>
|
|
5480
|
-
</svg>
|
|
5481
|
-
</button>
|
|
5482
5586
|
`}renderGitUpdateManagerButton(){let e=this.dndProps(`git-update-manager`),t=this.gitUpdateManagerCount>0?this.gitUpdateManagerCount:void 0,n=t===void 0?``:`${String(t)} changed file${t===1?``:`s`}`;return g`
|
|
5483
5587
|
<button
|
|
5484
5588
|
type="button"
|
|
@@ -5598,7 +5702,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5598
5702
|
<circle cx="12" cy="12" r="3"/>
|
|
5599
5703
|
</svg>
|
|
5600
5704
|
</button>
|
|
5601
|
-
`}render(){if(!(this.desktopMedia?.matches??!0))return g``;let e=this.railOrder.length===0?[...
|
|
5705
|
+
`}render(){if(!(this.desktopMedia?.matches??!0))return g``;let e=this.railOrder.length===0?[...GO]:this.railOrder;return g`
|
|
5602
5706
|
<nav
|
|
5603
5707
|
class="rail"
|
|
5604
5708
|
aria-label="Activity rail"
|
|
@@ -5672,128 +5776,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5672
5776
|
}
|
|
5673
5777
|
.rail-spacer { flex: 1 1 auto; min-height: 0; }
|
|
5674
5778
|
.settings-button { margin-bottom: 12px; }
|
|
5675
|
-
`}};B([x({attribute:!1})],
|
|
5676
|
-
<div
|
|
5677
|
-
class="browser-backdrop"
|
|
5678
|
-
role="dialog"
|
|
5679
|
-
aria-modal="true"
|
|
5680
|
-
aria-label="Browser"
|
|
5681
|
-
@click=${this.closeFromBackdrop}
|
|
5682
|
-
@keydown=${this.closeFromEscape}
|
|
5683
|
-
>
|
|
5684
|
-
<section class=${this.bounds===void 0?`browser-frame`:`browser-frame browser-frame-positioned`} style=${this.frameStyle()}>
|
|
5685
|
-
<header class="browser-header">
|
|
5686
|
-
<span
|
|
5687
|
-
class="browser-drag-handle"
|
|
5688
|
-
@pointerdown=${this.handleMovePointerDown}
|
|
5689
|
-
@pointermove=${this.handlePointerMove}
|
|
5690
|
-
@pointerup=${this.handlePointerUp}
|
|
5691
|
-
@pointercancel=${this.handlePointerCancel}
|
|
5692
|
-
>Browser</span>
|
|
5693
|
-
<span class="browser-zoom-controls" aria-label="Page zoom controls">
|
|
5694
|
-
<button type="button" class="browser-zoom-button" @click=${()=>{this.adjustZoom(-10)}} aria-label="Decrease page zoom">−</button>
|
|
5695
|
-
<span class="browser-zoom-value">${this.zoom}%</span>
|
|
5696
|
-
<button type="button" class="browser-zoom-button" @click=${()=>{this.adjustZoom(dk)}} aria-label="Increase page zoom">+</button>
|
|
5697
|
-
</span>
|
|
5698
|
-
<button type="button" class="browser-close-button" @click=${this.close} aria-label="Close browser">×</button>
|
|
5699
|
-
</header>
|
|
5700
|
-
<div class="browser-tabs" role="tablist" aria-label="Browser tabs">
|
|
5701
|
-
${this.browserTabs.tabs.map(e=>this.renderTab(e))}
|
|
5702
|
-
<button type="button" class="add-tab" @click=${this.addTab} aria-label="New tab" title="New tab">+</button>
|
|
5703
|
-
</div>
|
|
5704
|
-
<div class="address-area">
|
|
5705
|
-
<form class="address-form" @submit=${this.submitAddress}>
|
|
5706
|
-
<input
|
|
5707
|
-
type="text"
|
|
5708
|
-
inputmode="url"
|
|
5709
|
-
autocomplete="url"
|
|
5710
|
-
spellcheck="false"
|
|
5711
|
-
aria-label="Address"
|
|
5712
|
-
placeholder="Enter a web address"
|
|
5713
|
-
.value=${this.address}
|
|
5714
|
-
@input=${this.updateAddress}
|
|
5715
|
-
/>
|
|
5716
|
-
<button type="submit" class="navigate-button">Go</button>
|
|
5717
|
-
<button type="button" class="reload-button" @click=${this.reloadActiveTab} aria-label="Reload page" title="Reload page">↻</button>
|
|
5718
|
-
</form>
|
|
5719
|
-
<p class="browser-mode-notice">Lightweight embedded viewer. Remote browser mode is unavailable in this installation. Pages that block framing may not load.</p>
|
|
5720
|
-
${this.addressError===``?null:g`<p class="address-error" role="alert">${this.addressError}</p>`}
|
|
5721
|
-
</div>
|
|
5722
|
-
<div class="browser-page-viewport" role="tabpanel" aria-label="Browser page">
|
|
5723
|
-
${this.renderKeyedEmbeddedPage()}
|
|
5724
|
-
</div>
|
|
5725
|
-
<div
|
|
5726
|
-
class="browser-resize-handle"
|
|
5727
|
-
title="Drag to resize browser"
|
|
5728
|
-
aria-hidden="true"
|
|
5729
|
-
@pointerdown=${this.handleResizePointerDown}
|
|
5730
|
-
@pointermove=${this.handlePointerMove}
|
|
5731
|
-
@pointerup=${this.handlePointerUp}
|
|
5732
|
-
@pointercancel=${this.handlePointerCancel}
|
|
5733
|
-
></div>
|
|
5734
|
-
</section>
|
|
5735
|
-
</div>
|
|
5736
|
-
`}renderTab(e){let t=e.id===this.browserTabs.activeTabId,n=rk(e.url);return g`
|
|
5737
|
-
<span class=${t?`browser-tab selected`:`browser-tab`}>
|
|
5738
|
-
<button
|
|
5739
|
-
type="button"
|
|
5740
|
-
class="browser-tab-select"
|
|
5741
|
-
role="tab"
|
|
5742
|
-
aria-selected=${String(t)}
|
|
5743
|
-
title=${n}
|
|
5744
|
-
@click=${()=>{this.selectTab(e.id)}}
|
|
5745
|
-
>${n}</button>
|
|
5746
|
-
<button type="button" class="browser-tab-close" aria-label=${`Close ${n}`} @click=${()=>{this.closeTab(e.id)}}>×</button>
|
|
5747
|
-
</span>
|
|
5748
|
-
`}renderKeyedEmbeddedPage(){let e=this.activeTab();return e===void 0?v:ZO(`${e.id}:${String(e.reloadRevision)}`,this.renderEmbeddedPage())}renderEmbeddedPage(){let e=this.activeTab();if(e===void 0)return g``;let t=rk(e.url);return g`
|
|
5749
|
-
<div class="browser-page-scale" style=${`--browser-page-zoom: ${String(this.zoom/100)};`}>
|
|
5750
|
-
<iframe
|
|
5751
|
-
title=${`Browser: ${t}`}
|
|
5752
|
-
src=${e.url}
|
|
5753
|
-
sandbox="allow-forms allow-scripts"
|
|
5754
|
-
referrerpolicy="no-referrer"
|
|
5755
|
-
></iframe>
|
|
5756
|
-
</div>
|
|
5757
|
-
`}selectTab(e){let t=tk(this.browserTabs,{type:`select`,tabId:e});t!==this.browserTabs&&(this.browserTabs=t,this.address=pk(this.activeTab()),this.addressError=``)}closeTab(e){let t=tk(this.browserTabs,{type:`close`,tabId:e});if(t===this.browserTabs)return;this.browserTabs=t;let n=this.activeTab();this.address=pk(n),this.addressError=``,n===void 0&&this.close()}adjustZoom(e){let t=ik(this.zoom+e);t!==this.zoom&&(this.zoom=t,ok(t))}startPointerInteraction(e,t){if(t.button!==0)return;let n=t.currentTarget;if(!(n instanceof HTMLElement))return;let r=n.closest(`.browser-frame`);if(!(r instanceof HTMLElement))return;t.preventDefault(),t.stopPropagation();let i=Pg(this.boundsFromFrame(r),this.viewport());n.setPointerCapture(t.pointerId),this.bounds=i,this.pointerInteraction={operation:e,pointerId:t.pointerId,target:n,startClientX:t.clientX,startClientY:t.clientY,bounds:i}}boundsFromFrame(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}viewport(){return{width:window.innerWidth,height:window.innerHeight}}frameStyle(){let e=this.bounds;return e===void 0?``:`left: ${String(e.left)}px; top: ${String(e.top)}px; width: ${String(e.width)}px; height: ${String(e.height)}px;`}finishPointerInteraction(){let e=this.pointerInteraction;if(e!==void 0){try{e.target.releasePointerCapture(e.pointerId)}catch{}this.pointerInteraction=void 0}}activeTab(){let e=this.browserTabs.activeTabId;return e===void 0?void 0:this.browserTabs.tabs.find(t=>t.id===e)}static{this.styles=h`
|
|
5758
|
-
:host { position: fixed; inset: 0; z-index: 80; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
5759
|
-
* { box-sizing: border-box; }
|
|
5760
|
-
.browser-backdrop { width: 100%; height: 100dvh; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .48); }
|
|
5761
|
-
.browser-frame { position: relative; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); width: min(calc(100vw - 32px), 1280px); height: min(calc(100vh - 32px), 880px); overflow: hidden; border: 1px solid var(--pi-border); border-radius: 14px; background: var(--pi-bg); box-shadow: 0 20px 64px var(--pi-shadow-strong); }
|
|
5762
|
-
.browser-frame-positioned { position: fixed; }
|
|
5763
|
-
.browser-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--pi-border); background: var(--pi-surface); color: var(--pi-text); font-size: 14px; font-weight: 600; }
|
|
5764
|
-
.browser-drag-handle { flex: 1 1 auto; align-self: stretch; min-width: 0; display: flex; align-items: center; cursor: move; touch-action: none; -webkit-user-select: none; user-select: none; }
|
|
5765
|
-
.browser-zoom-controls { display: inline-flex; align-items: center; gap: 4px; }
|
|
5766
|
-
.browser-zoom-button, .browser-close-button, .add-tab, .navigate-button, .reload-button, .browser-tab-select, .browser-tab-close { border: 1px solid var(--pi-border); background: var(--pi-surface); color: var(--pi-text); cursor: pointer; }
|
|
5767
|
-
.browser-zoom-button, .browser-close-button { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border-radius: 6px; font-size: 16px; line-height: 1; }
|
|
5768
|
-
.browser-zoom-value { min-width: 38px; color: var(--pi-muted); font-size: 12px; font-weight: 400; text-align: center; }
|
|
5769
|
-
.browser-tabs { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 7px 10px; overflow-x: auto; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
5770
|
-
.browser-tab { display: inline-flex; flex: 0 0 auto; min-width: 0; overflow: hidden; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); }
|
|
5771
|
-
.browser-tab.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
5772
|
-
.browser-tab-select { min-width: 0; max-width: 180px; overflow: hidden; border: 0; padding: 5px 8px; background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
|
|
5773
|
-
.browser-tab-close { width: 26px; border: 0; border-left: 1px solid var(--pi-border); background: transparent; font-size: 16px; }
|
|
5774
|
-
.add-tab { flex: 0 0 auto; width: 28px; height: 28px; padding: 0; border-radius: 7px; font-size: 18px; line-height: 1; }
|
|
5775
|
-
.address-area { min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
5776
|
-
.address-form { display: flex; gap: 7px; min-width: 0; padding: 9px 10px; }
|
|
5777
|
-
.address-form input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; font: inherit; }
|
|
5778
|
-
.navigate-button, .reload-button { flex: 0 0 auto; border-radius: 7px; padding: 7px 9px; font: inherit; }
|
|
5779
|
-
.reload-button { width: 34px; padding: 0; font-size: 17px; }
|
|
5780
|
-
.browser-mode-notice { margin: -2px 10px 8px; color: var(--pi-muted); font-size: 12px; }
|
|
5781
|
-
.address-error { margin: 0; padding: 0 10px 8px; color: var(--pi-danger); font-size: 12px; }
|
|
5782
|
-
.browser-page-viewport { min-width: 0; min-height: 0; overflow: hidden; background: #fff; }
|
|
5783
|
-
.browser-page-scale { width: calc(100% / var(--browser-page-zoom)); height: calc(100% / var(--browser-page-zoom)); transform: scale(var(--browser-page-zoom)); transform-origin: top left; }
|
|
5784
|
-
iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
|
|
5785
|
-
.browser-resize-handle { position: absolute; right: 0; bottom: 0; z-index: 1; width: 20px; height: 20px; cursor: nwse-resize; touch-action: none; }
|
|
5786
|
-
.browser-resize-handle::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 7px; height: 7px; border-right: 2px solid var(--pi-muted); border-bottom: 2px solid var(--pi-muted); opacity: .7; }
|
|
5787
|
-
button:hover, button:focus-visible, input:focus-visible { border-color: var(--pi-accent); color: var(--pi-text); }
|
|
5788
|
-
button:focus-visible, input:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 1px; }
|
|
5789
|
-
.browser-resize-handle:hover::after { border-color: var(--pi-text); opacity: 1; }
|
|
5790
|
-
@media (max-width: 760px) {
|
|
5791
|
-
.browser-backdrop { padding: 0; }
|
|
5792
|
-
.browser-frame { width: 100%; height: 100%; border: 0; border-radius: 0; }
|
|
5793
|
-
.browser-frame-positioned { position: relative; }
|
|
5794
|
-
.browser-drag-handle { cursor: default; }
|
|
5795
|
-
}
|
|
5796
|
-
`}};B([x({attribute:!1})],fk.prototype,`onClose`,void 0),B([S()],fk.prototype,`browserTabs`,void 0),B([S()],fk.prototype,`address`,void 0),B([S()],fk.prototype,`addressError`,void 0),B([S()],fk.prototype,`zoom`,void 0),B([S()],fk.prototype,`bounds`,void 0),fk=B([b(`browser-panel`)],fk);function pk(e){return e===void 0||e.url===`about:blank`?``:e.url}var mk=class extends y{constructor(...e){super(...e),this.machineId=`local`,this.api=fo,this.loadingStatus=!1,this.loadingDiff=!1,this.error=``,this.statusRequest=0,this.diffRequest=0,this.refresh=async()=>{let e=this.workspace;if(e===void 0)return;let t=this.machineId,n=this.selectedChange?.id,r=++this.statusRequest;this.diffRequest+=1,this.status=void 0,this.selectedDiff=void 0,this.loadingStatus=!0,this.loadingDiff=!1,this.error=``;try{let i=await this.api.gitStatus(e.projectId,e.id,t);if(r!==this.statusRequest||!this.isCurrentWorkspace(e,t))return;this.status=i,this.loadingStatus=!1,this.onStatusChange?.(i);let a=n===void 0?void 0:gk(i,n);this.selectedChange=a,a!==void 0&&await this.loadDiff(a,e,t)}catch(n){if(r!==this.statusRequest||!this.isCurrentWorkspace(e,t))return;this.status=void 0,this.selectedChange=void 0,this.selectedDiff=void 0,this.loadingStatus=!1,this.error=yk(n)}},this.selectChange=e=>{let t=this.workspace;if(t===void 0)return;let n=this.machineId;this.selectedChange=e,this.selectedDiff=void 0,this.error=``,this.loadDiff(e,t,n)},this.onViewportResize=()=>{this.bounds!==void 0&&(this.bounds=Pg(this.bounds,this.viewport()))},this.handleMovePointerDown=e=>{this.startPointerInteraction(`move`,e)},this.handleResizePointerDown=e=>{this.startPointerInteraction(`resize`,e)},this.handlePointerMove=e=>{let t=this.pointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY};this.bounds=t.operation===`move`?Mg(t.bounds,n,this.viewport()):Ng(t.bounds,n,this.viewport())},this.handlePointerUp=e=>{this.pointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishPointerInteraction())},this.handlePointerCancel=e=>{this.pointerInteraction?.pointerId===e.pointerId&&this.finishPointerInteraction()},this.close=()=>{this.finishPointerInteraction(),this.onClose?.()}}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.onViewportResize),this.ensureWorkspaceScope()}willUpdate(){this.ensureWorkspaceScope()}disconnectedCallback(){this.finishPointerInteraction(),this.statusRequest+=1,this.diffRequest+=1,window.removeEventListener(`resize`,this.onViewportResize),super.disconnectedCallback()}render(){return g`
|
|
5779
|
+
`}};B([x({attribute:!1})],nk.prototype,`onOpenTerminal`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenGitUpdateManager`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenTheme`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenSystemPrompt`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenHistory`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenInfo`,void 0),B([x({attribute:!1})],nk.prototype,`onOpenSettings`,void 0),B([x({type:Number})],nk.prototype,`terminalCount`,void 0),B([x({type:Number})],nk.prototype,`gitUpdateManagerCount`,void 0),B([x({type:Boolean})],nk.prototype,`systemPromptEnabled`,void 0),B([x({type:Boolean})],nk.prototype,`historyEnabled`,void 0),B([x({attribute:!1})],nk.prototype,`railOrder`,void 0),B([x({attribute:!1})],nk.prototype,`onRailOrderChange`,void 0),nk=B([b(`activity-rail`)],nk);var rk=class extends y{constructor(...e){super(...e),this.machineId=`local`,this.api=fo,this.loadingStatus=!1,this.loadingDiff=!1,this.error=``,this.statusRequest=0,this.diffRequest=0,this.refresh=async()=>{let e=this.workspace;if(e===void 0)return;let t=this.machineId,n=this.selectedChange?.id,r=++this.statusRequest;this.diffRequest+=1,this.status=void 0,this.selectedDiff=void 0,this.loadingStatus=!0,this.loadingDiff=!1,this.error=``;try{let i=await this.api.gitStatus(e.projectId,e.id,t);if(r!==this.statusRequest||!this.isCurrentWorkspace(e,t))return;this.status=i,this.loadingStatus=!1,this.onStatusChange?.(i);let a=n===void 0?void 0:ak(i,n);this.selectedChange=a,a!==void 0&&await this.loadDiff(a,e,t)}catch(n){if(r!==this.statusRequest||!this.isCurrentWorkspace(e,t))return;this.status=void 0,this.selectedChange=void 0,this.selectedDiff=void 0,this.loadingStatus=!1,this.error=ck(n)}},this.selectChange=e=>{let t=this.workspace;if(t===void 0)return;let n=this.machineId;this.selectedChange=e,this.selectedDiff=void 0,this.error=``,this.loadDiff(e,t,n)},this.onViewportResize=()=>{this.bounds!==void 0&&(this.bounds=Pg(this.bounds,this.viewport()))},this.handleMovePointerDown=e=>{this.startPointerInteraction(`move`,e)},this.handleResizePointerDown=e=>{this.startPointerInteraction(`resize`,e)},this.handlePointerMove=e=>{let t=this.pointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY};this.bounds=t.operation===`move`?Mg(t.bounds,n,this.viewport()):Ng(t.bounds,n,this.viewport())},this.handlePointerUp=e=>{this.pointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishPointerInteraction())},this.handlePointerCancel=e=>{this.pointerInteraction?.pointerId===e.pointerId&&this.finishPointerInteraction()},this.close=()=>{this.finishPointerInteraction(),this.onClose?.()}}connectedCallback(){super.connectedCallback(),window.addEventListener(`resize`,this.onViewportResize),this.ensureWorkspaceScope()}willUpdate(){this.ensureWorkspaceScope()}disconnectedCallback(){this.finishPointerInteraction(),this.statusRequest+=1,this.diffRequest+=1,window.removeEventListener(`resize`,this.onViewportResize),super.disconnectedCallback()}render(){return g`
|
|
5797
5780
|
<div class="git-update-manager-backdrop" role="dialog" aria-modal="true" aria-label="Git Update Manager">
|
|
5798
5781
|
<section class=${this.bounds===void 0?`git-update-manager-frame`:`git-update-manager-frame git-update-manager-frame-positioned`} style=${this.frameStyle()}>
|
|
5799
5782
|
<header class="git-update-manager-header">
|
|
@@ -5827,15 +5810,15 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5827
5810
|
></div>
|
|
5828
5811
|
</section>
|
|
5829
5812
|
</div>
|
|
5830
|
-
`}ensureWorkspaceScope(){let e=
|
|
5813
|
+
`}ensureWorkspaceScope(){let e=sk(this.workspace,this.machineId);e!==this.workspaceScope&&(this.workspaceScope=e,this.statusRequest+=1,this.diffRequest+=1,this.status=void 0,this.selectedChange=void 0,this.selectedDiff=void 0,this.loadingStatus=!1,this.loadingDiff=!1,this.error=``,e!==void 0&&this.isConnected&&this.refresh())}renderChangeList(){if(this.loadingStatus)return g`<p class="git-update-manager-empty">Loading changes…</p>`;let e=this.status;if(e===void 0)return g`<p class="git-update-manager-empty">Refresh to load Git changes.</p>`;if(!e.isGitRepo)return g`<p class="git-update-manager-empty">This workspace is not a Git repository.</p>`;let t=vs(e.files);return t.staged.length===0&&t.unstaged.length===0?g`<p class="git-update-manager-empty">No Git changes.</p>`:g`
|
|
5831
5814
|
${this.renderChangeGroup(`staged`,t.staged)}
|
|
5832
5815
|
${this.renderChangeGroup(`unstaged`,t.unstaged)}
|
|
5833
|
-
`}renderChangeGroup(e,t){if(t.length===0)return null;let n=
|
|
5816
|
+
`}renderChangeGroup(e,t){if(t.length===0)return null;let n=ok(e);return g`
|
|
5834
5817
|
<section class="git-update-manager-change-group" aria-label=${`${n} changes`}>
|
|
5835
5818
|
<h2>${n} (${String(t.length)})</h2>
|
|
5836
5819
|
${t.map(e=>this.renderChange(e))}
|
|
5837
5820
|
</section>
|
|
5838
|
-
`}renderChange(e){let t=this.selectedChange?.id===e.id,n=Ss(e),r=xs(e.state),i=
|
|
5821
|
+
`}renderChange(e){let t=this.selectedChange?.id===e.id,n=Ss(e),r=xs(e.state),i=ok(e.scope);return g`
|
|
5839
5822
|
<button
|
|
5840
5823
|
type="button"
|
|
5841
5824
|
class=${`git-update-manager-entry ${t?`selected`:``}`}
|
|
@@ -5847,13 +5830,13 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5847
5830
|
<span class="git-update-manager-path">${n}</span>
|
|
5848
5831
|
<span class="git-update-manager-scope">${i}</span>
|
|
5849
5832
|
</button>
|
|
5850
|
-
`}renderDiffPreview(){let e=this.selectedChange;if(e===void 0)return g`<p class="git-update-manager-empty">Select a Git change to review.</p>`;if(this.error!==``)return g`<p class="git-update-manager-empty">Could not load ${Ss(e)}.</p>`;if(this.loadingDiff||this.selectedDiff===void 0)return g`<p class="git-update-manager-empty">Loading ${Ss(e)}…</p>`;let t=this.selectedDiff;return
|
|
5833
|
+
`}renderDiffPreview(){let e=this.selectedChange;if(e===void 0)return g`<p class="git-update-manager-empty">Select a Git change to review.</p>`;if(this.error!==``)return g`<p class="git-update-manager-empty">Could not load ${Ss(e)}.</p>`;if(this.loadingDiff||this.selectedDiff===void 0)return g`<p class="git-update-manager-empty">Loading ${Ss(e)}…</p>`;let t=this.selectedDiff;return ik(),g`
|
|
5851
5834
|
<header class="git-update-manager-diff-header">
|
|
5852
5835
|
<strong>${Ss(e)}</strong>
|
|
5853
|
-
<small>${
|
|
5836
|
+
<small>${ok(e.scope)} · ${xs(e.state)}${t.truncated?` · truncated`:``}</small>
|
|
5854
5837
|
</header>
|
|
5855
5838
|
<unified-diff-viewer .diff=${t.diff}></unified-diff-viewer>
|
|
5856
|
-
`}async loadDiff(e,t,n){let r=++this.diffRequest;this.loadingDiff=!0;try{let i=await this.api.gitDiff(t.projectId,t.id,{path:e.path,staged:e.scope===`staged`},n);if(r!==this.diffRequest||!this.isCurrentWorkspace(t,n)||this.selectedChange?.id!==e.id)return;this.selectedDiff=i,this.loadingDiff=!1,this.error=``}catch(i){if(r!==this.diffRequest||!this.isCurrentWorkspace(t,n)||this.selectedChange?.id!==e.id)return;this.selectedDiff=void 0,this.loadingDiff=!1,this.error=
|
|
5839
|
+
`}async loadDiff(e,t,n){let r=++this.diffRequest;this.loadingDiff=!0;try{let i=await this.api.gitDiff(t.projectId,t.id,{path:e.path,staged:e.scope===`staged`},n);if(r!==this.diffRequest||!this.isCurrentWorkspace(t,n)||this.selectedChange?.id!==e.id)return;this.selectedDiff=i,this.loadingDiff=!1,this.error=``}catch(i){if(r!==this.diffRequest||!this.isCurrentWorkspace(t,n)||this.selectedChange?.id!==e.id)return;this.selectedDiff=void 0,this.loadingDiff=!1,this.error=ck(i)}}startPointerInteraction(e,t){if(t.button!==0)return;let n=t.currentTarget;if(!(n instanceof HTMLElement))return;let r=n.closest(`.git-update-manager-frame`);if(!(r instanceof HTMLElement))return;t.preventDefault(),t.stopPropagation();let i=Pg(this.boundsFromFrame(r),this.viewport());n.setPointerCapture(t.pointerId),this.bounds=i,this.pointerInteraction={operation:e,pointerId:t.pointerId,target:n,startClientX:t.clientX,startClientY:t.clientY,bounds:i}}boundsFromFrame(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}viewport(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}frameStyle(){let e=this.bounds;return e===void 0?``:`left: ${String(e.left)}px; top: ${String(e.top)}px; width: ${String(e.width)}px; height: ${String(e.height)}px;`}finishPointerInteraction(){let e=this.pointerInteraction;if(e!==void 0){try{e.target.releasePointerCapture(e.pointerId)}catch{}this.pointerInteraction=void 0}}isCurrentWorkspace(e,t){return this.workspace?.id===e.id&&this.workspace.projectId===e.projectId&&this.machineId===t}static{this.styles=h`
|
|
5857
5840
|
:host { position: fixed; inset: 0; z-index: 80; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
5858
5841
|
.git-update-manager-backdrop { width: 100%; height: 100dvh; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .48); }
|
|
5859
5842
|
.git-update-manager-frame { position: relative; display: flex; flex-direction: column; width: min(calc(100vw - 32px), 1280px); height: min(calc(100vh - 32px), 880px); overflow: hidden; border: 1px solid var(--pi-border); border-radius: 14px; background: var(--pi-bg); box-shadow: 0 20px 64px var(--pi-shadow-strong); }
|
|
@@ -5892,7 +5875,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5892
5875
|
.git-update-manager-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(190px, 40%) minmax(0, 1fr); }
|
|
5893
5876
|
.git-update-manager-entries { border-right: 0; border-bottom: 1px solid var(--pi-border); }
|
|
5894
5877
|
}
|
|
5895
|
-
`}};B([x({attribute:!1})],mk.prototype,`onClose`,void 0),B([x({attribute:!1})],mk.prototype,`onStatusChange`,void 0),B([x({attribute:!1})],mk.prototype,`workspace`,void 0),B([x()],mk.prototype,`machineId`,void 0),B([x({attribute:!1})],mk.prototype,`api`,void 0),B([S()],mk.prototype,`status`,void 0),B([S()],mk.prototype,`selectedChange`,void 0),B([S()],mk.prototype,`selectedDiff`,void 0),B([S()],mk.prototype,`loadingStatus`,void 0),B([S()],mk.prototype,`loadingDiff`,void 0),B([S()],mk.prototype,`error`,void 0),B([S()],mk.prototype,`bounds`,void 0),mk=B([b(`git-update-manager-panel`)],mk);function hk(){rm(()=>import(`./UnifiedDiffViewer-BSrL6IvO.js`),[],import.meta.url)}function gk(e,t){let n=vs(e.files);return[...n.staged,...n.unstaged].find(e=>e.id===t)}function _k(e){return e===`staged`?`Staged`:`Unstaged`}function vk(e,t){return e===void 0?void 0:JSON.stringify([t,e.projectId,e.id])}function yk(e){return e instanceof Error?e.message:String(e)}var bk=900*1e3,xk=750,Sk=[1e3,3e3,8e3,15e3,3e4],Ck={capture:!0},wk=`auto:on`,Tk=`auto:off`,Ek=`theme:`,Dk=Qo(`core:workspace.files`),Ok=Qo(`core:workspace.git`),kk=Qo(`core:workspace.terminal`),Ak=320,jk=2,Mk=`(min-width: 1181px)`,$=class extends y{constructor(...e){super(...e),this.state=Bo(),this.sessionUnread=new qf({onChange:e=>{R(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.unreadSessionIds=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Dd(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.sessions=new Pu(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new wu,{notifications:this.notifications,onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t)},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(R(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)}}),this.projectActivityOwnership=new Rs(()=>this.state,e=>{this.setState(e)},{api:ro,onError:({machineId:e,projectId:t,error:n})=>{console.warn(`Failed to discover project activity ownership for ${t} on ${e}`,n)}}),this.activity=new Ko(()=>this.state,e=>{this.setState(e)},{onActivityApplied:e=>{this.projectActivityOwnership.handleActivityApplied(e)}}),this.auth=new Yo(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new Fd(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Nd),this.projects=new As(()=>this.state,e=>{this.setState(e)},this.workspaces,{onProjectsApplied:e=>{this.projectActivityOwnership.handleProjectsApplied(e)}}),this.machines=new Es(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebUiStatusController=new Bs(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEBUI status for ${e}`,t)}}),this.files=new ds(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new _s(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new af,this.realtime=new eu,this.machineRealtimeSockets=new Map,this.unreadRuntimeRefreshes=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new Bd,this.terminalSelection=new $d,this.appShell=new Oh(this),this.browserResume=new Ah({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.panelCollapse=new Kh(this),this.panelResize=new Xh(this),this.navigationSections=new Uh(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=Nk(),this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=fp()??cp,this.activeThemeId=sp,this.isRefreshingApp=!1,this.modelsConfigDialogOpen=!1,this.skillsConfigDialogOpen=!1,this.pluginsConfigDialogOpen=!1,this.systemPromptDialogOpen=!1,this.browserPanelOpen=!1,this.gitUpdateManagerPanelOpen=!1,this.terminalModalOpen=!1,this.terminalModalMaximized=!1,this.initialTerminalModalPreferences=Vg(),this.terminalModalFontSize=this.initialTerminalModalPreferences.fontSize,this.terminalModalOpacity=this.initialTerminalModalPreferences.opacity,this.terminalTabHidden=Qk(),this.infoTabHidden=tA(),this.railOrder=GO()??[...zO],this.settingsSection=_g(),this.shortcutConfig={},this.workspaceUploadDefaultFolder=bo(void 0),this.sessionWarningVisibility=tp(),this.onPopState=()=>void this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)}),this.onPageShow=()=>{this.renegotiateUnreadMachines(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onTerminalModalViewportResize=()=>{this.terminalModalBounds!==void 0&&(this.terminalModalBounds=Pg(this.terminalModalBounds,this.terminalModalViewport()))},this.onKeyDown=e=>{this.settingsSection!==void 0||this.state.treeDialog!==void 0||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.handleSendPrompt=(e,t,n,r)=>{this.sendPrompt(e,t,n,r)},this.handleStartSessionPrompt=(e,t,n,r)=>{!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)||(this.sessions.startSessionWithPrompt(e,t,n,r),this.focusChatComposer())},this.handleSelectStarterModel=()=>{this.openStarterModelDialog()},this.handleSelectStarterThinking=()=>{this.openStarterThinkingDialog()},this.handleOpenTerminalFromRail=()=>{this.state.selectedWorkspace!==void 0&&(this.terminalModalOpen=!0)},this.handleOpenBrowserFromRail=()=>{this.browserPanelOpen=!0},this.handleCloseBrowserPanel=()=>{this.browserPanelOpen=!1},this.handleOpenGitUpdateManagerFromRail=()=>{this.state.selectedWorkspace!==void 0&&(this.gitUpdateManagerPanelOpen=!0)},this.handleCloseGitUpdateManagerPanel=()=>{this.gitUpdateManagerPanelOpen=!1},this.handleOpenThemeFromRail=()=>{this.openThemeDialog()},this.handleRailOrderChange=e=>{this.railOrder=e,KO(e)},this.handleCloseTerminalModal=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalOpen=!1},this.toggleTerminalModalMaximized=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalMaximized=!this.terminalModalMaximized},this.handleTerminalModalMovePointerDown=e=>{this.startTerminalModalPointerInteraction(`move`,e)},this.handleTerminalModalResizePointerDown=e=>{this.startTerminalModalPointerInteraction(`resize`,e)},this.handleTerminalModalPointerMove=e=>{let t=this.terminalModalPointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY},r=this.terminalModalViewport();this.terminalModalBounds=t.operation===`move`?Mg(t.bounds,n,r):Ng(t.bounds,n,r)},this.handleTerminalModalPointerUp=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishTerminalModalPointerInteraction())},this.handleTerminalModalPointerCancel=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&this.finishTerminalModalPointerInteraction()},this.adjustTerminalFontSize=e=>{let t=zg(this.terminalModalFontSize+e);t!==this.terminalModalFontSize&&(this.terminalModalFontSize=t,this.persistTerminalModalPreferences())},this.adjustTerminalOpacity=e=>{let t=Bg(this.terminalModalOpacity+e);t!==this.terminalModalOpacity&&(this.terminalModalOpacity=t,this.persistTerminalModalPreferences())},this.handleStopActiveWork=()=>{this.sessions.stopActiveWork()},this.handleCompact=()=>{this.sessions.runCommand(`/compact`)},this.handleClearServerQueue=()=>{this.sessions.clearServerQueue()},this.handleEditFromHere=async(e,t)=>{let n=R(this.state),r=this.state.selectedSession?.id;try{!(await this.sessions.editFromHere(e,t)).cancelled&&r!==void 0&&R(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer()}catch{}},this.handleForkFromHere=async e=>{await this.sessions.forkFromHere(e)},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=op(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleSelectModel=()=>{this.openModelDialog()},this.handleSelectThinking=()=>{this.openThinkingDialog()}}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility()}updated(){this.committedChatIdentity=Ik(this.state),this.syncSelectedSessionReadState()}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=rp(this.sessionWarningVisibility,e===void 0?void 0:Wo(R(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=R(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}async commitReadyChatAfterRender(e,t){let n=Fk(e,t);await this.updateComplete,!(!this.unreadConnected||Ik(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions);Hk(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}syncWindowTitle(){this.disconnectWindowTitle();let e=Jg(this.state.selectedProject?.name);this.windowTitleCleanup=Yg(e)}disconnectWindowTitle(){this.windowTitleCleanup?.(),this.windowTitleCleanup=void 0}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=Fk(e,t);return Ik(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isChatObscured()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isChatObscured(){return this.settingsSection!==void 0||this.sessionCleanupDialog!==void 0||this.historyWindow!==void 0||this.modelsConfigDialogOpen||this.skillsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.pluginsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.systemPromptDialogOpen&&this.state.selectedSession!==void 0||this.state.actionPaletteOpen||this.state.projectDialogOpen||this.state.machineDialogOpen||this.state.commandDialog!==void 0||this.state.treeDialog!==void 0||this.state.modelDialog!==void 0||this.state.thinkingDialog!==void 0||this.state.themeDialog!==void 0||this.state.authDialog!==void 0||this.browserPanelOpen||this.gitUpdateManagerPanelOpen||this.terminalModalOpen}connectedCallback(){super.connectedCallback(),this.unreadConnected=!0,window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),window.addEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,Ck),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.renegotiateUnreadMachines(),this.piWebUiStatusTimer=window.setInterval(()=>{this.schedulePiWebUiStatusRefresh()},bk),this.refreshWorkspaceActivity(),this.loadClientConfig(),this.ensureGatewayPluginsLoaded(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebUiStatusRefresh()}),this.syncWindowTitle()}disconnectedCallback(){this.finishTerminalModalPointerInteraction(),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.unreadRuntimeRefreshes.clear(),this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),window.removeEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,Ck),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.git.dispose(),this.piWebUiStatusTimer!==void 0&&window.clearInterval(this.piWebUiStatusTimer),this.piWebUiStatusTimer=void 0,this.clearScheduledPiWebUiStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.clearPendingRemoteRouteRestore(),this.disconnectWindowTitle(),super.disconnectedCallback()}setState(e){if(!Vk(this.state,e))return;let t=this.state;this.state={...this.state,...e},Ik(t)!==Ik(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),Lk(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),!this.shouldShowSessionStartScreen(t)&&this.shouldShowSessionStartScreen(this.state)&&this.state.selectedWorkspace!==void 0&&this.loadStarterSessionDefaults(this.state.selectedWorkspace),this.handleMachineChange(t,this.state),Rk(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedProject?.name!==this.state.selectedProject?.name&&this.syncWindowTitle()}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=fg();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.schedulePiWebUiStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){await this.renegotiateUnreadMachines(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns()])}schedulePiWebUiStatusRefresh(e=xk){this.clearScheduledPiWebUiStatusRefresh(),this.piWebUiStatusDeferredTimer=window.setTimeout(()=>{this.piWebUiStatusDeferredTimer=void 0,this.piWebUiStatusController.refresh()},e)}clearScheduledPiWebUiStatusRefresh(){this.piWebUiStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebUiStatusDeferredTimer),this.piWebUiStatusDeferredTimer=void 0)}async refreshWorkspaceActivity(e=R(this.state)){try{await this.activity.refresh(e)}catch(t){console.warn(`Failed to refresh workspace activity for ${e}`,t)}}async refreshMachineActivities(){let e=this.state.machines.length===0?[R(this.state)]:this.state.machines.filter(e=>Bk(e,this.state.machineStatuses[e.id])).map(e=>e.id);await Promise.all(e.map(e=>this.refreshWorkspaceActivity(e)))}async loadClientConfig(){try{this.applyClientConfig((await Ua.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEBUI config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=bo(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.schedulePiWebUiStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.git`?await this.git.refreshGit():t===`core:workspace.terminal`&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(fg(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=R(this.state),a=e.projectId===void 0||e.projectId===``?Gk():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{await this.restoreRouteMachine(e,!1);let n=this.loadPluginsForSelectedMachine();if(e.tool?.startsWith(`machine.`)===!0&&await n,!this.isCurrentRouteRestore(o))return;if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:r??e.view??this.defaultRouteView(),selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),e.projectId===void 0||e.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(e)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl();return}let i=this.state.projects.find(t=>t.id===e.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedDiffPath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),R(this.state)!==i&&this.schedulePiWebUiStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?Gk():{selectedFilePath:es(Dk,`file`),selectedDiffPath:es(Ok,`diff`),selectedTerminalId:es(kk,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){pg(e,{replace:!0}),ts(Dk,`file`,void 0,{replace:!0}),ts(Ok,`diff`,void 0,{replace:!0}),ts(kk,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=qk(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=Sk.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`&&await this.files.refreshFiles(),e===`core:workspace.files`&&t!==void 0&&await this.files.restoreFile(t),e===`core:workspace.git`&&await this.git.refreshGit()}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await Xk(),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(),pg({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(Hd(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(Hd(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){pg(Ud(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){ts(Dk,`file`,e.selectedFilePath,{replace:!0}),ts(Ok,`diff`,e.selectedDiffPath,{replace:!0}),ts(kk,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??Vd(e.id);if(await this.restoreRouteFor(Ud(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=R(this.state)){let n=Kk(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=wg(e,{api:{runTerminalCommand:(e,n)=>ao.runTerminalCommand(e,n,t),listCommandRuns:e=>ao.listCommandRuns(e,t),getCommandRun:e=>ao.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}});return this.terminalCommandRunRuntimes.set(n,i),i}async openRuntimeTerminal(e,t,n){if((R(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),R(this.state)!==e)){this.setState({error:`Machine not found for terminal command run`});return}this.openTerminal(n)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){ts(kk,`terminal`,e,t)}terminalWorkspaceKey(e){return`${R(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}openSettings(e=`general`){this.settingsSection=e,vg(e)}closeSettings(){this.settingsSection=void 0,vg(void 0)}navigateSettings(e){this.settingsSection=e,vg(e)}restoreSettingsRoute(){this.settingsSection=_g()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.starterSessionDefaults=void 0,this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let n=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));this.setState({activeTerminalCount:0,selectedTerminalId:n}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(n,{replace:!0})),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling())}async loadStarterSessionDefaults(e){let t=R(this.state);try{let n=await io.sessionDefaults(e.path,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.starterSessionDefaults=n}catch(n){R(this.state)===t&&this.state.selectedWorkspace?.id===e.id&&console.warn(`Failed to load Pi session defaults`,n)}}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));this.sessionUnread.retainMachines(e);for(let t of e){let e=this.state.machineRuntimes[t];if(e===void 0)continue;let n=this.unreadRuntimeRefreshes.has(t)||!e.ok?`unknown`:Gt(e,T.sessionsUnread)?`supported`:`unsupported`;this.sessionUnread.setCapability(t,n)&&this.sessionUnread.refresh(t)}}async renegotiateUnreadMachines(){if(!this.unreadConnected)return;let e=new Set(this.state.machines.map(e=>e.id));e.add(R(this.state)),await Promise.all([...e].map(async e=>{await this.renegotiateUnreadMachine(e)}))}renegotiateUnreadMachine(e){let t=this.unreadRuntimeRefreshes.get(e);if(t!==void 0)return t;this.sessionUnread.setCapability(e,`unknown`);let n=!1,r=Promise.resolve().then(async()=>{n=await this.machines.refreshMachineRuntime(e)!==void 0});this.unreadRuntimeRefreshes.set(e,r);let i=()=>{this.unreadRuntimeRefreshes.get(e)===r&&(this.unreadRuntimeRefreshes.delete(e),this.unreadConnected&&(n?this.syncSessionUnreadMachines():this.sessionUnread.setCapability(e,`unknown`)))};return r.then(i,i),r}connectRealtime(){let e=R(this.state);this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.renegotiateUnreadMachine(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t),this.refreshWorkspaceActivity(e)},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new eu;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.renegotiateUnreadMachine(t),this.refreshWorkspaceActivity(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=R(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>zk(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`&&this.activity.applyWorkspaceActivity(t.activity,e)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`?this.activity.applyWorkspaceActivity(t.activity):Wk(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=R(this.state);try{let n=await ao.terminals(e.projectId,e.id,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=Uk(e),r=Uk(t);n&&!r&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)&&(this.projectActivityOwnership.handleSelectedMachineChanged(),(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({piWebUiStatus:void 0}),this.git.updatePolling(),this.loadPluginsForSelectedMachine())}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`&&this.files.refreshFiles(),e===`core:workspace.git`&&this.git.refreshGit()}renderWorkspacePanel(){let e=this.state.selectedWorkspace;return g`
|
|
5878
|
+
`}};B([x({attribute:!1})],rk.prototype,`onClose`,void 0),B([x({attribute:!1})],rk.prototype,`onStatusChange`,void 0),B([x({attribute:!1})],rk.prototype,`workspace`,void 0),B([x()],rk.prototype,`machineId`,void 0),B([x({attribute:!1})],rk.prototype,`api`,void 0),B([S()],rk.prototype,`status`,void 0),B([S()],rk.prototype,`selectedChange`,void 0),B([S()],rk.prototype,`selectedDiff`,void 0),B([S()],rk.prototype,`loadingStatus`,void 0),B([S()],rk.prototype,`loadingDiff`,void 0),B([S()],rk.prototype,`error`,void 0),B([S()],rk.prototype,`bounds`,void 0),rk=B([b(`git-update-manager-panel`)],rk);function ik(){rm(()=>import(`./UnifiedDiffViewer-iSh_gYQc.js`),[],import.meta.url)}function ak(e,t){let n=vs(e.files);return[...n.staged,...n.unstaged].find(e=>e.id===t)}function ok(e){return e===`staged`?`Staged`:`Unstaged`}function sk(e,t){return e===void 0?void 0:JSON.stringify([t,e.projectId,e.id])}function ck(e){return e instanceof Error?e.message:String(e)}var lk=900*1e3,uk=750,dk=[1e3,3e3,8e3,15e3,3e4],fk={capture:!0},pk=`auto:on`,mk=`auto:off`,hk=`theme:`,gk=Qo(`core:workspace.files`),_k=Qo(`core:workspace.git`),vk=Qo(`core:workspace.terminal`),yk=320,bk=2,xk=`(min-width: 1181px)`,$=class extends y{constructor(...e){super(...e),this.state=Bo(),this.sessionUnread=new qf({onChange:e=>{R(this.state)===e&&(this.syncUnreadSessionIds(),this.syncSelectedSessionReadState())},onBackgroundError:(e,t,n)=>{console.warn(`Failed to ${e} session unread state for ${t}`,n)}}),this.unreadSessionIds=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions),this.unreadConnected=!1,this.notifications=new Dd(()=>this.state,e=>{this.setState(e)},{onBackgroundError:(e,t)=>{console.warn(e,t)}}),this.sessions=new Pu(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},new wu,{notifications:this.notifications,onSelectedSessionReady:({machineId:e,session:t})=>{this.commitReadyChatAfterRender(e,t)},replacePromptEditorText:async({machineId:e,sessionId:t,text:n})=>{await this.updateComplete,!(R(this.state)!==e||this.state.selectedSession?.id!==t)&&this.promptEditor?.replaceText(n)}}),this.projectActivityOwnership=new Rs(()=>this.state,e=>{this.setState(e)},{api:ro,onError:({machineId:e,projectId:t,error:n})=>{console.warn(`Failed to discover project activity ownership for ${t} on ${e}`,n)}}),this.activity=new Ko(()=>this.state,e=>{this.setState(e)},{onActivityApplied:e=>{this.projectActivityOwnership.handleActivityApplied(e)}}),this.auth=new Yo(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new Fd(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions,new Nd),this.projects=new As(()=>this.state,e=>{this.setState(e)},this.workspaces,{onProjectsApplied:e=>{this.projectActivityOwnership.handleProjectsApplied(e)}}),this.machines=new Es(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.projects),this.piWebUiStatusController=new Bs(()=>this.state,e=>{this.setState(e)},{onRefreshError:(e,t)=>{console.warn(`Failed to refresh PI WEBUI status for ${e}`,t)}}),this.files=new ds(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new _s(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new af,this.realtime=new eu,this.machineRealtimeSockets=new Map,this.unreadRuntimeRefreshes=new Map,this.activeTerminalIds=new Set,this.machineNavigation=new Bd,this.terminalSelection=new $d,this.appShell=new Oh(this),this.browserResume=new Ah({onResumeSignal:()=>{this.handleBrowserResumeSignal()},refreshAfterResume:()=>this.refreshAfterBrowserResume(),onRefreshError:e=>{console.warn(`Failed to refresh after browser resume`,e)}}),this.panelCollapse=new Kh(this),this.panelResize=new Xh(this),this.navigationSections=new Uh(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=Sk(),this.loadedMachinePluginIds=new Set,this.machinePluginLoadPromises=new Map,this.themePreference=fp()??cp,this.activeThemeId=sp,this.isRefreshingApp=!1,this.modelsConfigDialogOpen=!1,this.projectBrowserOpen=!1,this.skillsConfigDialogOpen=!1,this.pluginsConfigDialogOpen=!1,this.systemPromptDialogOpen=!1,this.gitUpdateManagerPanelOpen=!1,this.terminalModalOpen=!1,this.terminalModalMaximized=!1,this.initialTerminalModalPreferences=Vg(),this.terminalModalFontSize=this.initialTerminalModalPreferences.fontSize,this.terminalModalOpacity=this.initialTerminalModalPreferences.opacity,this.terminalTabHidden=Vk(),this.infoTabHidden=Wk(),this.railOrder=ZO()??[...GO],this.settingsSection=_g(),this.shortcutConfig={},this.workspaceUploadDefaultFolder=bo(void 0),this.sessionWarningVisibility=tp(),this.onPopState=()=>void this.withChatScrollTransition(async()=>{this.restoreSettingsRoute(),await this.restoreRoute(!1)}),this.onPageShow=()=>{this.renegotiateUnreadMachines(),this.appShell.repairViewportPosition(),this.retryPendingRemoteRouteRestoreSoon()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onTerminalModalViewportResize=()=>{this.terminalModalBounds!==void 0&&(this.terminalModalBounds=Pg(this.terminalModalBounds,this.terminalModalViewport()))},this.onKeyDown=e=>{this.settingsSection!==void 0||this.state.treeDialog!==void 0||this.keyboard.handle(e,this.getDefaultActions(),{shortcuts:this.shortcutConfig})&&(e.preventDefault(),e.stopPropagation())},this.handleSendPrompt=(e,t,n,r)=>{this.sendPrompt(e,t,n,r)},this.handleStartSessionPrompt=(e,t,n,r)=>{!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)||(this.sessions.startSessionWithPrompt(e,t,n,r),this.focusChatComposer())},this.handleSelectStarterModel=()=>{this.openStarterModelDialog()},this.handleSelectStarterThinking=()=>{this.openStarterThinkingDialog()},this.handleOpenTerminalFromRail=()=>{this.state.selectedWorkspace!==void 0&&(this.terminalModalOpen=!0)},this.handleOpenGitUpdateManagerFromRail=()=>{this.state.selectedWorkspace!==void 0&&(this.gitUpdateManagerPanelOpen=!0)},this.handleCloseGitUpdateManagerPanel=()=>{this.gitUpdateManagerPanelOpen=!1},this.handleOpenThemeFromRail=()=>{this.openThemeDialog()},this.handleRailOrderChange=e=>{this.railOrder=e,QO(e)},this.handleCloseTerminalModal=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalOpen=!1},this.toggleTerminalModalMaximized=()=>{this.finishTerminalModalPointerInteraction(),this.terminalModalMaximized=!this.terminalModalMaximized},this.handleTerminalModalMovePointerDown=e=>{this.startTerminalModalPointerInteraction(`move`,e)},this.handleTerminalModalResizePointerDown=e=>{this.startTerminalModalPointerInteraction(`resize`,e)},this.handleTerminalModalPointerMove=e=>{let t=this.terminalModalPointerInteraction;if(t?.pointerId!==e.pointerId)return;e.preventDefault();let n={x:e.clientX-t.startClientX,y:e.clientY-t.startClientY},r=this.terminalModalViewport();this.terminalModalBounds=t.operation===`move`?Mg(t.bounds,n,r):Ng(t.bounds,n,r)},this.handleTerminalModalPointerUp=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&(e.preventDefault(),this.finishTerminalModalPointerInteraction())},this.handleTerminalModalPointerCancel=e=>{this.terminalModalPointerInteraction?.pointerId===e.pointerId&&this.finishTerminalModalPointerInteraction()},this.adjustTerminalFontSize=e=>{let t=zg(this.terminalModalFontSize+e);t!==this.terminalModalFontSize&&(this.terminalModalFontSize=t,this.persistTerminalModalPreferences())},this.adjustTerminalOpacity=e=>{let t=Bg(this.terminalModalOpacity+e);t!==this.terminalModalOpacity&&(this.terminalModalOpacity=t,this.persistTerminalModalPreferences())},this.handleStopActiveWork=()=>{this.sessions.stopActiveWork()},this.handleCompact=()=>{this.sessions.runCommand(`/compact`)},this.handleClearServerQueue=()=>{this.sessions.clearServerQueue()},this.handleEditFromHere=async(e,t)=>{let n=R(this.state),r=this.state.selectedSession?.id;try{!(await this.sessions.editFromHere(e,t)).cancelled&&r!==void 0&&R(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer()}catch{}},this.handleForkFromHere=async e=>{await this.sessions.forkFromHere(e)},this.handleDismissWarning=e=>{this.sessions.dismissWarning(e)},this.handleDismissNotification=e=>{this.notifications.dismissNotification(e)},this.handleDismissAllNotifications=()=>{this.notifications.dismissAll()},this.handleToggleWarnings=()=>{let e=op(this.sessionWarningVisibility);e!==this.sessionWarningVisibility&&(this.sessionWarningVisibility=e,this.requestUpdate())},this.handleSelectModel=()=>{this.openModelDialog()},this.handleSelectThinking=()=>{this.openThinkingDialog()}}get routeRestoreInProgress(){return this.routeRestoreDepth>0}willUpdate(){this.toggleAttribute(`pwa-display-mode`,this.appShell.isPwaDisplayMode),this.syncSessionWarningVisibility()}updated(){this.committedChatIdentity=Tk(this.state),this.syncSelectedSessionReadState()}syncSessionWarningVisibility(){let e=this.state.selectedSession;this.sessionWarningVisibility=rp(this.sessionWarningVisibility,e===void 0?void 0:Wo(R(this.state),e.id),this.state.status===void 0?void 0:this.state.status.warnings??[])}syncSelectedSessionReadState(){let e=this.state.selectedSession;if(e===void 0)return;let t=R(this.state);this.isSessionSeen(t,e)&&this.sessionUnread.acknowledge(t,e)}async commitReadyChatAfterRender(e,t){let n=wk(e,t);await this.updateComplete,!(!this.unreadConnected||Tk(this.state)!==n)&&(this.readyChatIdentity=n,this.syncSelectedSessionReadState())}syncUnreadSessionIds(){let e=this.sessionUnread.unreadSessionIds(R(this.state),this.state.sessions);jk(e,this.unreadSessionIds)||(this.unreadSessionIds=e)}syncWindowTitle(){this.disconnectWindowTitle();let e=Jg(this.state.selectedProject?.name);this.windowTitleCleanup=Yg(e)}disconnectWindowTitle(){this.windowTitleCleanup?.(),this.windowTitleCleanup=void 0}isSessionSeen(e,t){if(!this.unreadConnected)return!1;let n=wk(e,t);return Tk(this.state)!==n||this.committedChatIdentity!==n||this.readyChatIdentity!==n||typeof document<`u`&&(document.visibilityState!==`visible`||typeof document.hasFocus==`function`&&!document.hasFocus())||this.isChatObscured()?!1:this.state.mainView===`chat`?!0:this.state.mainView===`navigation`?!this.appShell.isMobileNavigationLayout:this.isDesktopSideBySideLayout()}isChatObscured(){return this.settingsSection!==void 0||this.sessionCleanupDialog!==void 0||this.historyWindow!==void 0||this.modelsConfigDialogOpen||this.skillsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.pluginsConfigDialogOpen&&this.state.selectedWorkspace!==void 0||this.systemPromptDialogOpen&&this.state.selectedSession!==void 0||this.state.actionPaletteOpen||this.projectBrowserOpen||this.state.projectDialogOpen||this.state.machineDialogOpen||this.state.commandDialog!==void 0||this.state.treeDialog!==void 0||this.state.modelDialog!==void 0||this.state.thinkingDialog!==void 0||this.state.themeDialog!==void 0||this.state.authDialog!==void 0||this.gitUpdateManagerPanelOpen||this.terminalModalOpen}connectedCallback(){super.connectedCallback(),this.unreadConnected=!0,window.addEventListener(`popstate`,this.onPopState),window.addEventListener(`pageshow`,this.onPageShow),window.addEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.connect(),window.addEventListener(`keydown`,this.onKeyDown,fk),this.systemLightThemeMedia?.addEventListener(`change`,this.onSystemLightThemeChange),this.applyPreferredTheme(!1),this.connectRealtime(),this.renegotiateUnreadMachines(),this.piWebUiStatusTimer=window.setInterval(()=>{this.schedulePiWebUiStatusRefresh()},lk),this.refreshWorkspaceActivity(),this.loadClientConfig(),this.ensureGatewayPluginsLoaded(),this.loadProjectsAndRestoreRoute().finally(()=>{this.schedulePiWebUiStatusRefresh()}),this.syncWindowTitle()}disconnectedCallback(){this.finishTerminalModalPointerInteraction(),this.unreadConnected=!1,this.committedChatIdentity=void 0,this.readyChatIdentity=void 0,this.unreadRuntimeRefreshes.clear(),this.sessionUnread.retainMachines(new Set),window.removeEventListener(`popstate`,this.onPopState),window.removeEventListener(`pageshow`,this.onPageShow),window.removeEventListener(`resize`,this.onTerminalModalViewportResize),this.browserResume.disconnect(),window.removeEventListener(`keydown`,this.onKeyDown,fk),this.systemLightThemeMedia?.removeEventListener(`change`,this.onSystemLightThemeChange),this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.notifications.dispose(),this.realtime.close(),this.closeMachineActivitySockets(),this.git.dispose(),this.piWebUiStatusTimer!==void 0&&window.clearInterval(this.piWebUiStatusTimer),this.piWebUiStatusTimer=void 0,this.clearScheduledPiWebUiStatusRefresh(),this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.clearPendingRemoteRouteRestore(),this.disconnectWindowTitle(),super.disconnectedCallback()}setState(e){if(!Ak(this.state,e))return;let t=this.state;this.state={...this.state,...e},Tk(t)!==Tk(this.state)&&(this.committedChatIdentity=void 0,this.readyChatIdentity=void 0),Ek(t,this.state)&&this.syncSessionUnreadMachines(),this.syncUnreadSessionIds(),this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state),!this.shouldShowSessionStartScreen(t)&&this.shouldShowSessionStartScreen(this.state)&&this.state.selectedWorkspace!==void 0&&this.loadStarterSessionDefaults(this.state.selectedWorkspace),this.handleMachineChange(t,this.state),Dk(t,this.state)&&this.syncMachineActivitySubscriptions(),this.notifications.syncEnvironment(t,this.state),t.selectedProject?.name!==this.state.selectedProject?.name&&this.syncWindowTitle()}async loadProjectsAndRestoreRoute(){this.restoreSettingsRoute();let e=fg();await this.machines.loadMachines(e.machineId);let t=this.routeForSelectedMachine(e),n=this.state.machineStatuses[t.machineId??`local`];t!==e&&this.replaceRouteAndClearWorkspaceQuery(t),await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRouteFor(t,!1)),this.shouldDeferRemoteRouteRestore(t,n)?this.deferRemoteRouteRestore(t):(this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation()),await this.refreshWorkspaceDeletionRuns()}handleBrowserResumeSignal(){this.appShell.repairViewportPosition(),this.schedulePiWebUiStatusRefresh(),this.retryPendingRemoteRouteRestoreSoon()}async refreshAfterBrowserResume(){await this.renegotiateUnreadMachines(),await Promise.all([this.sessions.refreshSelectedSession(),this.refreshMachineActivities(),this.refreshWorkspaceDeletionRuns()])}schedulePiWebUiStatusRefresh(e=uk){this.clearScheduledPiWebUiStatusRefresh(),this.piWebUiStatusDeferredTimer=window.setTimeout(()=>{this.piWebUiStatusDeferredTimer=void 0,this.piWebUiStatusController.refresh()},e)}clearScheduledPiWebUiStatusRefresh(){this.piWebUiStatusDeferredTimer!==void 0&&(window.clearTimeout(this.piWebUiStatusDeferredTimer),this.piWebUiStatusDeferredTimer=void 0)}async refreshWorkspaceActivity(e=R(this.state)){try{await this.activity.refresh(e)}catch(t){console.warn(`Failed to refresh workspace activity for ${e}`,t)}}async refreshMachineActivities(){let e=this.state.machines.length===0?[R(this.state)]:this.state.machines.filter(e=>kk(e,this.state.machineStatuses[e.id])).map(e=>e.id);await Promise.all(e.map(e=>this.refreshWorkspaceActivity(e)))}async loadClientConfig(){try{this.applyClientConfig((await Ua.config()).effectiveConfig)}catch(e){console.warn(`Failed to load PI WEBUI config`,e)}}applyClientConfig(e){this.shortcutConfig=e.shortcuts??{},this.workspaceUploadDefaultFolder=bo(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.schedulePiWebUiStatusRefresh()}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){let e=this.state.selectedWorkspace,t=this.state.mainView!==`chat`&&this.state.mainView!==`navigation`?this.state.mainView:this.state.workspaceTool;t===`core:workspace.files`?await this.files.refreshFiles():t===`core:workspace.git`?await this.git.refreshGit():t===`core:workspace.terminal`&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){await this.restoreRouteFor(fg(),e),this.rememberCurrentMachineNavigation()}async restoreRouteFor(e,t,n=this.readWorkspaceRouteSurface(e),r){let i=R(this.state),a=e.projectId===void 0||e.projectId===``?Pk():n,o=++this.routeRestoreSeq;this.routeRestoreDepth+=1,this.restoringRouteTerminalId=a.selectedTerminalId;try{await this.restoreRouteMachine(e,!1);let n=this.loadPluginsForSelectedMachine();if(e.tool?.startsWith(`machine.`)===!0&&await n,!this.isCurrentRouteRestore(o))return;if(this.setState({workspaceTool:e.tool??this.state.workspaceTool,mainView:r??e.view??this.defaultRouteView(),selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),e.projectId===void 0||e.projectId===``){t&&this.updateUrl();return}if(this.routeMatchesCurrentSelection(e)){a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl();return}let i=this.state.projects.find(t=>t.id===e.projectId);if(!i){this.setState({selectedFilePath:void 0,selectedDiffPath:void 0,selectedTerminalId:void 0}),t&&this.updateUrl();return}if(await this.workspaces.selectProject(i,{workspaceId:e.workspaceId,sessionId:e.sessionId,updateUrl:!1}),!this.isCurrentRouteRestore(o))return;this.setState({selectedFilePath:a.selectedFilePath,selectedDiffPath:a.selectedDiffPath,selectedTerminalId:a.selectedTerminalId}),a.selectedTerminalId!==void 0&&this.rememberSelectedTerminal(a.selectedTerminalId),await this.refreshRestoredWorkspaceTool(e.tool,a.selectedFilePath),this.git.updatePolling(),t&&this.updateUrl()}finally{this.routeRestoreDepth=Math.max(0,this.routeRestoreDepth-1),this.routeRestoreDepth===0&&(this.restoringRouteTerminalId=void 0),R(this.state)!==i&&this.schedulePiWebUiStatusRefresh()}}isCurrentRouteRestore(e){return e===this.routeRestoreSeq}readWorkspaceRouteSurface(e){return e.projectId===void 0||e.projectId===``?Pk():{selectedFilePath:es(gk,`file`),selectedDiffPath:es(_k,`diff`),selectedTerminalId:es(vk,`terminal`)}}routeForSelectedMachine(e){let t=this.state.selectedMachine?.id??`local`;return(e.machineId??`local`)===t?e:{machineId:t,projectId:void 0,workspaceId:void 0,sessionId:void 0,tool:void 0,view:void 0}}replaceRouteAndClearWorkspaceQuery(e){pg(e,{replace:!0}),ts(gk,`file`,void 0,{replace:!0}),ts(_k,`diff`,void 0,{replace:!0}),ts(vk,`terminal`,void 0,{replace:!0})}shouldDeferRemoteRouteRestore(e,t=this.state.machineStatuses[e.machineId??`local`]){let n=e.machineId??`local`,r=this.state.selectedMachine;return n===`local`||r?.id!==n||r.kind!==`remote`||t?.ok!==!1?!1:e.projectId===void 0||e.projectId===``?this.state.projects.length===0:this.state.selectedProject?.id!==e.projectId}deferRemoteRouteRestore(e){this.pendingRemoteRouteRestore=e,this.remoteRouteRestoreAttempt=0,this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}retryPendingRemoteRouteRestoreSoon(){this.pendingRemoteRouteRestore!==void 0&&this.schedulePendingRemoteRouteRestore(0)}schedulePendingRemoteRouteRestore(e=Ik(this.remoteRouteRestoreAttempt)){this.pendingRemoteRouteRestore!==void 0&&(this.clearPendingRemoteRouteRestoreTimer(),this.remoteRouteRestoreTimer=window.setTimeout(()=>{this.remoteRouteRestoreTimer=void 0,this.retryPendingRemoteRouteRestore()},e))}async retryPendingRemoteRouteRestore(){if(this.remoteRouteRestoreInProgress)return;let e=this.pendingRemoteRouteRestore;if(e!==void 0){if(!this.pendingRemoteRouteRestoreStillCurrent(e)){this.clearPendingRemoteRouteRestore();return}this.remoteRouteRestoreInProgress=!0;try{let t=e.machineId??`local`,n=await this.machines.refreshMachineHealth(t);if(!this.pendingRemoteRouteRestoreStillCurrent(e))return;if(n?.ok!==!0){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.machines.refreshMachineRuntime(t),!this.pendingRemoteRouteRestoreStillCurrent(e)||(await this.projects.loadProjects(),!this.pendingRemoteRouteRestoreStillCurrent(e)))return;if(this.state.error!==``){this.scheduleNextRemoteRouteRestoreAttempt(e);return}if(await this.withChatScrollTransition(()=>this.restoreRouteFor(e,!1)),!this.pendingRemoteRouteRestoreStillCurrent(e))return;this.clearPendingRemoteRouteRestore(),this.rememberCurrentMachineNavigation(),await this.refreshWorkspaceDeletionRuns()}finally{this.remoteRouteRestoreInProgress=!1}}}scheduleNextRemoteRouteRestoreAttempt(e){if(this.remoteRouteRestoreAttempt+=1,this.remoteRouteRestoreAttempt>=dk.length){this.setRemoteRouteRestoreMessage(e,{exhausted:!0}),this.clearPendingRemoteRouteRestore();return}this.setRemoteRouteRestoreMessage(e),this.schedulePendingRemoteRouteRestore()}setRemoteRouteRestoreMessage(e,t={}){let n=e.machineId??`local`,r=this.state.machines.find(e=>e.id===n)?.name??this.state.selectedMachine?.name??`Remote machine`,i=this.state.machineStatuses[n]?.error??(this.state.error===``?void 0:this.state.error),a=t.exhausted===!0?`${r} is still unavailable.`:`${r} is unavailable; reconnecting…`;this.setState({error:`${a}${i===void 0?``:` ${i}`}`})}pendingRemoteRouteRestoreStillCurrent(e){let t=e.machineId??`local`;return t!==`local`&&this.pendingRemoteRouteRestore===e&&this.state.selectedMachine?.id===t&&this.state.machines.some(e=>e.id===t)}clearPendingRemoteRouteRestore(){this.clearPendingRemoteRouteRestoreTimer(),this.pendingRemoteRouteRestore=void 0,this.remoteRouteRestoreAttempt=0}clearPendingRemoteRouteRestoreTimer(){this.remoteRouteRestoreTimer!==void 0&&(window.clearTimeout(this.remoteRouteRestoreTimer),this.remoteRouteRestoreTimer=void 0)}async restoreRouteMachine(e,t){let n=e.machineId??`local`;if(this.state.selectedMachine?.id===n)return;let r=this.state.machines.find(e=>e.id===n);r!==void 0&&await this.machines.selectMachine(r,{updateUrl:t})}routeMatchesCurrentSelection(e){return(e.machineId??`local`)===(this.state.selectedMachine?.id??`local`)&&e.workspaceId!==void 0&&e.workspaceId!==``&&this.state.selectedProject?.id===e.projectId&&this.state.selectedWorkspace?.id===e.workspaceId&&this.state.selectedSession?.id===e.sessionId}async refreshRestoredWorkspaceTool(e,t){e===`core:workspace.files`&&await this.files.refreshFiles(),e===`core:workspace.files`&&t!==void 0&&await this.files.restoreFile(t),e===`core:workspace.git`&&await this.git.refreshGit()}async withChatScrollTransition(e,t=()=>!0){this.chatView?.saveScrollPosition(),await e(),t()&&(await this.updateComplete,t()&&(await this.chatView?.updateComplete,t()&&(await zk(),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(),pg({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(Hd(this.state))}syncWorkspaceRouteSurfaceToUrl(){this.writeWorkspaceRouteSurfaceToUrl(Hd(this.state).surface)}writeMachineNavigationSnapshotToUrl(e,t){pg(Ud(e),t),this.writeWorkspaceRouteSurfaceToUrl(e.surface)}writeWorkspaceRouteSurfaceToUrl(e){ts(gk,`file`,e.selectedFilePath,{replace:!0}),ts(_k,`diff`,e.selectedDiffPath,{replace:!0}),ts(vk,`terminal`,e.selectedTerminalId,{replace:!0})}async selectMachineWithMemory(e,t={}){if(this.state.selectedMachine?.id===e.id)return;t.rememberCurrent!==!1&&!this.routeRestoreInProgress&&this.rememberCurrentMachineNavigation();let n=++this.machineNavigationRestoreSeq,r=this.machineNavigation.latest(e.id)??Vd(e.id);if(await this.restoreRouteFor(Ud(r),!1,r.surface,r.view),!(n!==this.machineNavigationRestoreSeq||this.state.selectedMachine?.id!==e.id)){if(this.shouldPreserveUnrestoredMachineNavigation(r)){this.machineNavigation.remember(r),this.writeMachineNavigationSnapshotToUrl(r);return}this.updateUrl()}}shouldPreserveUnrestoredMachineNavigation(e){return e.projectId!==void 0&&this.state.selectedProject?.id!==e.projectId&&this.state.error!==``}openWorkspaceTool(e){e===`core:workspace.terminal`&&(this.terminalAutoStartWorkspaceId=this.state.selectedWorkspace?.id),this.setState({workspaceTool:e,mainView:e}),this.updateUrl(),this.refreshSelectedWorkspaceTool(e),this.git.updatePolling()}openTerminal(e){e?.terminalId!==void 0&&this.selectTerminal(e.terminalId,{replace:!0}),this.openWorkspaceTool(`core:workspace.terminal`)}terminalCommandRunsForOrigin(e,t=R(this.state)){let n=Fk(t,e),r=this.terminalCommandRunRuntimes.get(n);if(r!==void 0)return r;let i=wg(e,{api:{runTerminalCommand:(e,n)=>ao.runTerminalCommand(e,n,t),listCommandRuns:e=>ao.listCommandRuns(e,t),getCommandRun:e=>ao.getCommandRun(e,t)},openTerminal:(e,n)=>{this.openRuntimeTerminal(t,e,n)}});return this.terminalCommandRunRuntimes.set(n,i),i}async openRuntimeTerminal(e,t,n){if((R(this.state)!==e||t!==void 0&&(this.state.selectedWorkspace?.id!==t.id||this.state.selectedProject?.id!==t.projectId))&&(this.routeRestoreInProgress||this.rememberCurrentMachineNavigation(),await this.restoreRouteFor({machineId:e,projectId:t?.projectId,workspaceId:t?.id,sessionId:void 0,tool:`core:workspace.terminal`,view:`core:workspace.terminal`},!1,{selectedTerminalId:n?.terminalId},`core:workspace.terminal`),R(this.state)!==e)){this.setState({error:`Machine not found for terminal command run`});return}this.openTerminal(n)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){let t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(this.terminalWorkspaceKey(t)):this.terminalSelection.rememberTerminal(this.terminalWorkspaceKey(t),e))}writeSelectedTerminalToUrl(e,t){ts(vk,`terminal`,e,t)}terminalWorkspaceKey(e){return`${R(this.state)}:${e.path}`}selectMainView(e){if(e!==`navigation`&&e!==`chat`){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}openSettings(e=`general`){this.settingsSection=e,vg(e)}closeSettings(){this.settingsSection=void 0,vg(void 0)}navigateSettings(e){this.settingsSection=e,vg(e)}restoreSettingsRoute(){this.settingsSection=_g()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.starterSessionDefaults=void 0,this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();let n=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(this.terminalWorkspaceKey(t.selectedWorkspace));this.setState({activeTerminalCount:0,selectedTerminalId:n}),this.routeRestoreInProgress||(this.rememberCurrentMachineNavigation(),this.writeSelectedTerminalToUrl(n,{replace:!0})),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling())}async loadStarterSessionDefaults(e){let t=R(this.state);try{let n=await io.sessionDefaults(e.path,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.starterSessionDefaults=n}catch(n){R(this.state)===t&&this.state.selectedWorkspace?.id===e.id&&console.warn(`Failed to load Pi session defaults`,n)}}syncSessionUnreadMachines(){if(!this.unreadConnected){this.sessionUnread.retainMachines(new Set);return}let e=new Set(this.state.machines.map(e=>e.id));this.sessionUnread.retainMachines(e);for(let t of e){let e=this.state.machineRuntimes[t];if(e===void 0)continue;let n=this.unreadRuntimeRefreshes.has(t)||!e.ok?`unknown`:Gt(e,T.sessionsUnread)?`supported`:`unsupported`;this.sessionUnread.setCapability(t,n)&&this.sessionUnread.refresh(t)}}async renegotiateUnreadMachines(){if(!this.unreadConnected)return;let e=new Set(this.state.machines.map(e=>e.id));e.add(R(this.state)),await Promise.all([...e].map(async e=>{await this.renegotiateUnreadMachine(e)}))}renegotiateUnreadMachine(e){let t=this.unreadRuntimeRefreshes.get(e);if(t!==void 0)return t;this.sessionUnread.setCapability(e,`unknown`);let n=!1,r=Promise.resolve().then(async()=>{n=await this.machines.refreshMachineRuntime(e)!==void 0});this.unreadRuntimeRefreshes.set(e,r);let i=()=>{this.unreadRuntimeRefreshes.get(e)===r&&(this.unreadRuntimeRefreshes.delete(e),this.unreadConnected&&(n?this.syncSessionUnreadMachines():this.sessionUnread.setCapability(e,`unknown`)))};return r.then(i,i),r}connectRealtime(){let e=R(this.state);this.realtime.connect(t=>{this.handleRealtimeEvent(e,t)},()=>{this.renegotiateUnreadMachine(e);let t=this.state.selectedWorkspace;t!==void 0&&this.refreshActiveTerminals(t),this.refreshWorkspaceActivity(e)},e)}syncMachineActivitySubscriptions(){let e=this.machineActivitySubscriptionIds();for(let[t,n]of this.machineRealtimeSockets.entries())e.has(t)||(n.close(),this.machineRealtimeSockets.delete(t));for(let t of e){if(this.machineRealtimeSockets.has(t))continue;let e=new eu;e.connect(e=>{this.handleMachineActivityEvent(t,e)},()=>{this.renegotiateUnreadMachine(t),this.refreshWorkspaceActivity(t)},t),this.machineRealtimeSockets.set(t,e)}}closeMachineActivitySockets(){for(let e of this.machineRealtimeSockets.values())e.close();this.machineRealtimeSockets.clear()}machineActivitySubscriptionIds(){let e=R(this.state);return new Set(this.state.machines.filter(t=>t.id!==e).filter(e=>Ok(e,this.state.machineStatuses[e.id])).map(e=>e.id))}handleMachineActivityEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`&&this.activity.applyWorkspaceActivity(t.activity,e)}handleRealtimeEvent(e,t){t.type===`sessions.unread`?this.sessionUnread.applyEvent(e,t):t.type===`workspace.activity`?this.activity.applyWorkspaceActivity(t.activity):Nk(t)?(this.applyTerminalEvent(t),t.type===`terminal.exited`&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(t)}applyTerminalEvent(e){let t=this.state.selectedWorkspace;t!==void 0&&(e.type===`terminal.closed`?e.cwd:e.terminal.cwd)===t.path&&(e.type===`terminal.created`&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type===`terminal.closed`?e.terminalId:e.terminal.id),e.type===`terminal.closed`&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){let t=R(this.state);try{let n=await ao.terminals(e.projectId,e.id,t);if(R(this.state)!==t||this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(let e of n)e.exited||this.activeTerminalIds.add(e.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(e){this.setState({error:String(e)})}}handleActivityTransition(e,t){let n=Mk(e),r=Mk(t);n&&!r&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}handleMachineChange(e,t){(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)&&(this.projectActivityOwnership.handleSelectedMachineChanged(),(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({piWebUiStatus:void 0}),this.git.updatePolling(),this.loadPluginsForSelectedMachine())}refreshSelectedWorkspaceTool(e){e===`core:workspace.files`&&this.files.refreshFiles(),e===`core:workspace.git`&&this.git.refreshGit()}renderWorkspacePanel(){let e=this.state.selectedWorkspace;return g`
|
|
5896
5879
|
<workspace-panel
|
|
5897
5880
|
id="workspace-panel"
|
|
5898
5881
|
.workspace=${e}
|
|
@@ -5939,7 +5922,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5939
5922
|
.onResizeEnd=${()=>{this.panelResize.persistPanelSizes()}}
|
|
5940
5923
|
.onReset=${()=>{this.resetResizablePanel(`workspace`)}}
|
|
5941
5924
|
></app-panel-edge-control>
|
|
5942
|
-
`}startPanelResize(e){return e===`navigation`?this.panelCollapse.expandNavigationPanel():this.panelCollapse.expandWorkspacePanel(),this.measuredPanelWidth(e)??this.panelResize.panelWidth(e)}resizablePanelConstraints(e){let t=this.panelResize.constraints(e);return{...t,maxWidth:this.resizablePanelMaxWidth(e,t)}}resizablePanelMaxWidth(e,t){let n=this.getBoundingClientRect().width||(typeof window>`u`?0:window.innerWidth);if(n<=0)return t.maxWidth;let r=this.oppositeResizablePanelWidth(e),i=Math.floor(n-r-
|
|
5925
|
+
`}startPanelResize(e){return e===`navigation`?this.panelCollapse.expandNavigationPanel():this.panelCollapse.expandWorkspacePanel(),this.measuredPanelWidth(e)??this.panelResize.panelWidth(e)}resizablePanelConstraints(e){let t=this.panelResize.constraints(e);return{...t,maxWidth:this.resizablePanelMaxWidth(e,t)}}resizablePanelMaxWidth(e,t){let n=this.getBoundingClientRect().width||(typeof window>`u`?0:window.innerWidth);if(n<=0)return t.maxWidth;let r=this.oppositeResizablePanelWidth(e),i=Math.floor(n-r-bk-yk);return Math.max(t.minWidth,Math.min(t.maxWidth,i))}oppositeResizablePanelWidth(e){let 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)||window.matchMedia(xk).matches}measuredPanelWidth(e){let t=(e===`navigation`?this.navigationPanelFrame:this.workspacePanelFrame)?.getBoundingClientRect().width;return t===void 0||t<=0?void 0:t}resetResizablePanel(e){this.panelResize.resetPanel(e)}resetResizablePanels(){this.panelResize.resetPanels()}canDeleteArchivedSessions(){let e=this.selectedMachineRuntime();return e?.ok!==!0||Gt(e,T.sessionsDeleteArchived)}canReloadSessions(){let e=this.selectedMachineRuntime();return e?.ok===!0&&Gt(e,T.sessionsReload)}canClearServerQueue(){let e=this.selectedMachineRuntime();return e?.ok===!0&&Gt(e,T.sessionsClearQueue)}canMessageActions(){let e=this.selectedMachineRuntime();return e?.ok===!0&&Gt(e,T.sessionsMessageActions)}canViewSystemPrompt(){let e=this.selectedMachineRuntime();return e?.ok===!0&&Gt(e,T.sessionsSystemPrompt)}canCleanupSessions(){let e=this.selectedMachineRuntime();return e?.ok===!0&&Gt(e,T.sessionsCleanup)}hasAuthoritativeSessionPersistence(){return du(this.selectedMachineRuntime())}supportsWorkspaceFileSuggestions(e=R(this.state)){if(e===`local`)return!0;let t=this.state.machineRuntimes[e];return t?.ok===!0&&Gt(t,T.workspaceFileSuggestions)}archivedDeleteUnavailableMessage(){return`Update and restart Pi-Web on ${this.state.selectedMachine?.name??`this machine`} to delete archived sessions.`}sessionCleanupUnavailableMessage(){return Bf(this.state.selectedMachine?.name)}selectedMachineRuntime(){return this.state.machineRuntimes[R(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}let t=R(this.state);this.sessionCleanupDialog={...this.sessionCleanupDialog??{},loading:!0,error:``,preview:void 0,previewRequest:void 0,result:void 0};try{let n=await io.cleanupPreview(e,t);if(R(this.state)!==t)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:n,previewRequest:e,result:void 0,loading:!1,error:``}}catch(e){R(this.state)===t&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,loading:!1,error:`Failed to preview cleanup: ${Lk(e)}`})}}async runSessionCleanup(e){let t=this.sessionCleanupDialog;if(t?.preview===void 0||Nf(t.previewRequest)!==Nf(e)){this.sessionCleanupDialog={...t??{},error:`Preview cleanup before running it.`};return}if(!this.canCleanupSessions()){this.sessionCleanupDialog={...t,error:this.sessionCleanupUnavailableMessage(),running:!1};return}let n=R(this.state);this.sessionCleanupDialog={...t,running:!0,error:``};try{let t=await io.cleanup(e,n);if(R(this.state)!==n)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,preview:t,previewRequest:e,result:t,running:!1,error:``},await this.sessions.applySessionCleanupResult(t,n)}catch(e){R(this.state)===n&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,running:!1,error:`Failed to run cleanup: ${Lk(e)}`})}}async runForceSessionCleanup(){let e=this.sessionCleanupDialog;if(!this.canCleanupSessions()){this.sessionCleanupDialog={...e??{},error:this.sessionCleanupUnavailableMessage(),runningForce:!1};return}let t=R(this.state);this.sessionCleanupDialog={...e??{},runningForce:!0,error:``};try{let e=await io.forceCleanup(t);if(R(this.state)!==t)return;this.sessionCleanupDialog={...this.sessionCleanupDialog,forceCleanupResult:e,runningForce:!1,error:``},await this.sessions.applySessionCleanupResult(e,t)}catch(e){R(this.state)===t&&(this.sessionCleanupDialog={...this.sessionCleanupDialog,runningForce:!1,error:`Failed to force cleanup: ${Lk(e)}`})}}renderNavigationPanel(){return g`
|
|
5943
5926
|
<app-navigation-panel
|
|
5944
5927
|
.machines=${this.state.machines}
|
|
5945
5928
|
.selectedMachine=${this.state.selectedMachine}
|
|
@@ -5987,6 +5970,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
5987
5970
|
.onOpenPlugins=${()=>{this.state.selectedWorkspace!==void 0&&(this.pluginsConfigDialogOpen=!0)}}
|
|
5988
5971
|
.onToggleProjects=${()=>{this.navigationSections.toggle(`projects`)}}
|
|
5989
5972
|
.onAddProject=${()=>{this.openProjectDialog()}}
|
|
5973
|
+
.onOpenProjectBrowser=${e=>{this.openProjectBrowser(e)}}
|
|
5990
5974
|
.onToggleWorkspaces=${()=>{this.navigationSections.toggle(`workspaces`)}}
|
|
5991
5975
|
.onToggleSessions=${()=>{this.navigationSections.toggle(`sessions`)}}
|
|
5992
5976
|
.onSelectProject=${e=>this.selectNavigationItem(`projects`,`workspaces`,()=>this.workspaces.selectProject(e))}
|
|
@@ -6013,7 +5997,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6013
5997
|
.onFocusNavigationTarget=${e=>{this.focusNavigationTarget(e)}}
|
|
6014
5998
|
.onCancelKeyboardNavigation=${()=>{this.focusChatComposer()}}
|
|
6015
5999
|
></app-navigation-panel>
|
|
6016
|
-
`}canOpenSessionHistory(){let e=this.state.selectedSession;return e!==void 0&&e.persisted!==!1&&e.path!==``}openSessionHistory(){let e=this.state.selectedSession;e===void 0||!this.canOpenSessionHistory()||(this.historyWindow={machineId:R(this.state),session:e})}openNavigationSection(e){this.navigationSections.open(e,()=>{this.selectMainView(`navigation`)})}cancelPendingNavigationSelection(){this.navigationSelectionSeq+=1}async selectNavigationItem(e,t,n){let r=++this.navigationSelectionSeq,i=()=>r===this.navigationSelectionSeq;await this.withChatScrollTransition(async()=>{this.navigationSections.advanceAfterSelection(e),await n()},i),i()&&await this.focusNavigationTarget(t)}async selectSessionFromNavigation(e){if(this.state.selectedWorkspace?.path===e.cwd){await this.sessions.selectSession(e);return}let t=this.state.workspaces.find(t=>t.path===e.cwd);if(t===void 0){this.setState({error:`The session's workspace is no longer available.`});return}await this.workspaces.selectWorkspace(t,{sessionId:e.id})}async startSessionFromNavigation(){let e=++this.navigationSelectionSeq;this.navigationSections.advanceAfterSelection(`sessions`),await this.startSessionAndOpenChat(()=>e===this.navigationSelectionSeq)}async startSessionAndOpenChat(e=()=>!0){this.sessions.startSession().catch(t=>{e()&&this.setState({error:String(t)})}),e()&&await this.focusChatComposer()}async focusNavigationTarget(e){if(e===`chat`){await this.focusChatComposer();return}await this.focusNavigationSection(e)}async focusNavigationSection(e){if(e===`machines`&&!
|
|
6000
|
+
`}canOpenSessionHistory(){let e=this.state.selectedSession;return e!==void 0&&e.persisted!==!1&&e.path!==``}openSessionHistory(){let e=this.state.selectedSession;e===void 0||!this.canOpenSessionHistory()||(this.historyWindow={machineId:R(this.state),session:e})}openNavigationSection(e){this.navigationSections.open(e,()=>{this.selectMainView(`navigation`)})}cancelPendingNavigationSelection(){this.navigationSelectionSeq+=1}async selectNavigationItem(e,t,n){let r=++this.navigationSelectionSeq,i=()=>r===this.navigationSelectionSeq;await this.withChatScrollTransition(async()=>{this.navigationSections.advanceAfterSelection(e),await n()},i),i()&&await this.focusNavigationTarget(t)}async selectSessionFromNavigation(e){if(this.state.selectedWorkspace?.path===e.cwd){await this.sessions.selectSession(e);return}let t=this.state.workspaces.find(t=>t.path===e.cwd);if(t===void 0){this.setState({error:`The session's workspace is no longer available.`});return}await this.workspaces.selectWorkspace(t,{sessionId:e.id})}async startSessionFromNavigation(){let e=++this.navigationSelectionSeq;this.navigationSections.advanceAfterSelection(`sessions`),await this.startSessionAndOpenChat(()=>e===this.navigationSelectionSeq)}async startSessionAndOpenChat(e=()=>!0){this.sessions.startSession().catch(t=>{e()&&this.setState({error:String(t)})}),e()&&await this.focusChatComposer()}async focusNavigationTarget(e){if(e===`chat`){await this.focusChatComposer();return}await this.focusNavigationSection(e)}async focusNavigationSection(e){if(e===`machines`&&!NO(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 zk(),await this.navigationPanel?.focusSection(e)}async focusChatComposer(){this.state.mainView!==`chat`&&this.selectMainView(`chat`),await this.updateComplete,await zk(),this.promptEditor?.focusInput()}async navigateSessionTree(e,t){let n=R(this.state),r=this.state.selectedSession?.id,i=await this.sessions.navigateTree(e,t);return!i.cancelled&&r!==void 0&&R(this.state)===n&&this.state.selectedSession?.id===r&&await this.focusChatComposer(),i}closeSessionTreeNavigator(){this.sessions.closeTreeDialog(),this.focusChatComposer()}renderSessionTreeNavigator(e){return e.treeDialog===void 0?null:g`
|
|
6017
6001
|
<session-tree-navigator
|
|
6018
6002
|
.tree=${e.treeDialog}
|
|
6019
6003
|
.onNavigate=${(e,t)=>this.navigateSessionTree(e,t)}
|
|
@@ -6032,7 +6016,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6032
6016
|
<p class="session-start-hint">Describe a goal, paste a task, or attach a file to begin.</p>
|
|
6033
6017
|
</div>
|
|
6034
6018
|
</section>
|
|
6035
|
-
`}mobilePanelBadge(e){let 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){let t=Pk(this.state);return{machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,t.id),host:this.createWorkspaceHost()}}createWorkspaceFiles(e,t){return{readFile:n=>ro.workspaceFile(e.projectId,e.id,n,t),writeFile:async(n,r,i)=>{let a=await ro.writeWorkspaceFile(e.projectId,e.id,n,r,i,t);return this.files.refreshFiles(),a},deleteFile:async n=>{let r=await ro.deleteWorkspaceFile(e.projectId,e.id,n,t);return this.files.refreshFiles(),r},moveFile:async(n,r,i)=>{let a=await ro.moveWorkspaceFile(e.projectId,e.id,n,r,i,t);return this.files.refreshFiles(),a}}}createWorkspaceHost(){return{requestRender:()=>{this.requestUpdate()}}}createWorkspacePanelContext(e){let t=Pk(this.state),n=t.id,r=i=>{let a=this.terminalCommandRunsForOrigin(i,n);return gh({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,n),prompt:this.createPromptEditor(),terminal:{open:t=>{this.openRuntimeTerminal(n,e,t)},runCommand:t=>a.runCommand({...t,workspace:e})},openTerminal:t=>{this.openRuntimeTerminal(n,e,t)},host:this.createWorkspaceHost(),piWebUiUnstable:{terminalCommandRuns:a},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:xo(e.effectiveConfig,this.workspaceUploadDefaultFolder),onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:e=>{this.files.expandDir(e)},onSelectFile:e=>{this.files.selectFile(e)},onStartWorkspaceUpload:(e,t)=>this.files.startWorkspaceUpload(e,t),onCancelWorkspaceUpload:e=>{this.files.cancelWorkspaceUpload(e)},onClearWorkspaceUpload:e=>{this.files.clearWorkspaceUpload(e)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:e=>{this.git.selectDiff(e)},onSelectTerminal:(e,t)=>{this.selectTerminal(e,t)}},r)};return r(`core`)}getActions(){return xg(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.toggle-terminal-tab`,title:this.terminalTabHidden?`Show Terminal Tab`:`Hide Terminal Tab`,description:this.terminalTabHidden?`Show the terminal tab in the workspace panel`:`Hide the terminal tab from the workspace panel`,group:`View`,run:()=>{this.toggleTerminalTab()}},{id:`app.layout.toggle-info-tab`,title:this.infoTabHidden?`Show Info Tab`:`Hide Info Tab`,description:this.infoTabHidden?`Show the info tab in the workspace panel`:`Hide the info tab from the workspace panel`,group:`View`,run:()=>{this.toggleInfoTab()}},{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 WEBUI plugins`,()=>$m())}async loadPluginsForSelectedMachine(){let 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;let t=this.machinePluginLoadPromises.get(e.id);if(t!==void 0)return t;let n=this.registerExternalPlugins(`PI WEBUI plugins from ${e.name}`,()=>$m(`api/machines/${encodeURIComponent(e.id)}/pi-webui-plugins/manifest.json`,{machineId:e.id,shouldLoadPlugin:e=>this.plugins.shouldLoadRemotePlugin(e.id,e.machineSpecific)})).then(t=>{t&&this.loadedMachinePluginIds.add(e.id)}).finally(()=>{this.machinePluginLoadPromises.delete(e.id)});this.machinePluginLoadPromises.set(e.id,n),await n}async registerExternalPlugins(e,t){try{let e=await t();for(let t of e)try{this.plugins.register(t)}catch(e){console.warn(`Failed to register PI WEBUI plugin ${t.id}`,e)}return this.applyPreferredTheme(!1),this.requestUpdate(),!0}catch(t){return console.warn(`Failed to load ${e}`,t),!1}}createPromptEditor(){return{insertText:e=>{let t=this.promptEditor?.view;if(!t)return;t.hasFocus||t.focus();let n=t.state.selection.main;t.dispatch({changes:{from:n.from,to:n.to,insert:e},selection:{anchor:n.from+e.length}})},getText:()=>this.promptEditor?.view?.state.doc.toString()??``,getSelection:()=>{let e=this.promptEditor?.view;if(!e)return null;let t=e.state.selection.main;return t.empty?null:{start:t.from,end:t.to,text:e.state.sliceDoc(t.from,t.to)}}}}createPluginRuntimeContext(){let e=t=>hh({state:this.state,prompt:this.createPromptEditor(),piWebUiUnstable:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t),openSettings:e=>{this.openSettings(e)}},openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.focusChatComposer()},addProject:()=>{this.openProjectDialog()},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:e=>{this.selectMainView(e)},selectWorkspaceTool:e=>{this.openWorkspaceTool(e)},openTerminal:e=>{this.openTerminal(e)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),refreshAppData:()=>this.refreshAppData(),checkForPiWebUiUpdates:()=>this.piWebUiStatusController.checkForUpdates(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:e=>this.deleteWorkspace(e),startSession:()=>this.withChatScrollTransition(()=>this.startSessionAndOpenChat()),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(!Id(e)){this.setState({error:`Only secondary Git worktrees can be deleted`});return}if(Op(this.state,e))return;let t=e.branch??e.label;if(!confirm(`Delete workspace ${t}?\n\nThis will run git worktree remove and delete:\n${e.path}\n\nThe Git branch will not be deleted.`))return;let n=R(this.state);try{let t=await ro.deleteWorkspace(e.projectId,e.id,n);if(R(this.state)!==n)return;this.recordWorkspaceDeletionRun(t,n);let r=await this.workspaceForCommandRun(t);if(R(this.state)!==n)return;r!==void 0&&this.openRuntimeTerminal(n,r,{terminalId:t.terminalId})}catch(e){R(this.state)===n&&this.setState({error:`Failed to start workspace deletion: ${Jk(e)}`})}}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(t=>t.id===e.workspaceId)}recordWorkspaceDeletionRun(e,t){if(R(this.state)!==t)return;let n=kp(e);n!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[n]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;let e=R(this.state),t=this.state.selectedProject;if(t===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{let n=await this.terminalCommandRunsForOrigin(`core`,e).listCommandRuns(Tp(t.id));if(R(this.state)!==e)return;let r=Ep(n);this.setState({workspaceDeletionRuns:r});for(let t of Object.values(r))Ap(t)||await this.handleCompletedWorkspaceDeletionRun(t,e)}catch(e){console.warn(`Failed to refresh workspace deletion runs`,e)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){let e=Object.values(this.state.workspaceDeletionRuns).some(Ap);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=R(this.state)){if(R(this.state)!==t)return;let n=Kk(t,e.id);if(this.handledWorkspaceDeletionRunIds.has(n))return;let r=kp(e);if(r!==void 0){if(this.handledWorkspaceDeletionRunIds.add(n),e.status===`succeeded`){if(await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,r),R(this.state)!==t)return;this.setState({workspaceDeletionRuns:Yk(this.state.workspaceDeletionRuns,r)}),this.updateWorkspaceDeletionPolling();return}e.status===`failed`&&(this.setState({error:`Workspace deletion failed. See terminal output.`}),this.updateWorkspaceDeletionPolling())}}openProjectDialog(){this.setState({projectDialogOpen:!0})}openMachineDialog(){this.setState({machineDialogOpen:!0,error:``})}async submitMachineDialog(e){await this.machines.addMachine(e)!==void 0&&(this.setState({machineDialogOpen:!1}),this.schedulePiWebUiStatusRefresh())}async removeMachine(e=this.state.selectedMachine){if(e===void 0||e.kind===`local`||!window.confirm(`Remove ${e.name}?\n\nThis only removes it from this PI WEBUI gateway.`))return;let t=this.state.selectedMachine?.id===e.id;t&&this.rememberCurrentMachineNavigation();let n=await this.machines.deleteMachine(e,{selectFallback:!t});this.state.machines.some(t=>t.id===e.id)||this.machineNavigation.forget(e.id),t&&n!==void 0&&await this.selectMachineWithMemory(n,{rememberCurrent:!1})}openSelectedMachine(){let 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=>{let n=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${n}`})})}async openModelDialog(){let e=await this.sessions.listModels(),t=this.state.status?.model?.provider,n=this.state.status?.model?.id,r=[...e].sort((e,t)=>{let n=e.provider??``,r=t.provider??``;return n===r?(e.id??``).localeCompare(t.id??``):n.localeCompare(r)});this.setState({modelDialog:{title:`Select Model`,...t!==void 0&&n!==void 0?{selectedValue:`${t}/${n}`}:{},options:r.map(e=>{let r=e.provider??``,i=e.id??``,a=r===t&&i===n;return{value:`${r}/${i}`,label:i+(a?` ✓ current`:``),...r===``?{}:{group:r}}})}})}async pickModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openStarterModelDialog(){let e=this.starterSessionDefaults;if(e===void 0)return;let t=e.model?.provider,n=e.model?.id,r=[...e.models].sort((e,t)=>{let n=e.provider??``,r=t.provider??``;return n===r?(e.id??``).localeCompare(t.id??``):n.localeCompare(r)});this.setState({modelDialog:{title:`Select Default Model`,source:`starter`,...t!==void 0&&n!==void 0?{selectedValue:`${t}/${n}`}:{},options:r.map(e=>{let r=e.provider??``,i=e.id??``,a=r===t&&i===n;return{value:`${r}/${i}`,label:i+(a?` ✓ current`:``),...r===``?{}:{group:r}}})}})}async pickStarterModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.updateStarterSessionDefaults({model:{provider:e.slice(0,t),modelId:e.slice(t+1)}})}openThemeDialog(){let e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),n=t.selectedTheme?.id,r=this.themePreference.auto?Tk:wk;this.setState({themeDialog:{title:`Select Theme`,selectedValue:n===void 0?r:`${Ek}${n}`,options:[{value:r,label:`Auto ${this.themePreference.auto?`✓ on`:`off`}`,description:this.autoThemeDescription(t)},...e.map(e=>({value:`${Ek}${e.id}`,label:this.themeOptionLabel(e,n),description:this.themeOptionDescription(e)}))]}})}pickTheme(e){if(this.setState({themeDialog:void 0}),e===wk||e===Tk){let t=this.resolveCurrentThemePreference().selectedTheme?.id;if(t===void 0)return;this.themePreference={themeId:t,auto:e===wk},this.applyPreferredTheme(!0);return}if(!e.startsWith(Ek))return;let t=e.slice(6),n=this.plugins.getThemes().find(e=>e.id===t);n!==void 0&&(this.themePreference={themeId:n.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){let t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,mp(t),e&&pp(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return hp({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return _p(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){let n=[...e.id===t?[`selected`]:[],...e.id===this.activeThemeId&&e.id!==t?[`active`]:[]];return n.length===0?e.name:`${e.name} ✓ ${n.join(` · `)}`}themeOptionDescription(e){let 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(){let e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??`off`;this.setState({thinkingDialog:{title:`Select Thinking Level`,selectedValue:t,options:e.map(e=>{let n=rA(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.sessions.setThinkingLevel(e)}openStarterThinkingDialog(){let e=this.starterSessionDefaults;if(e===void 0)return;let t=e.thinkingLevel;this.setState({thinkingDialog:{title:`Select Default Thinking Level`,source:`starter`,selectedValue:t,options:e.thinkingLevels.map(e=>{let n=rA(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickStarterThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.updateStarterSessionDefaults({thinkingLevel:e})}async updateStarterSessionDefaults(e){let t=this.state.selectedWorkspace;if(t===void 0)return;let n=R(this.state);try{let r=await io.updateSessionDefaults(t.path,e,n);if(R(this.state)!==n||this.state.selectedWorkspace?.id!==t.id)return;this.starterSessionDefaults=r}catch(e){R(this.state)===n&&this.state.selectedWorkspace?.id===t.id&&this.setState({error:String(e)})}}sendPrompt(e,t,n,r){!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)||this.sessions.send(e,t,n,r)}applyGitUpdateManagerStatus(e,t,n){let r=this.state.selectedWorkspace;R(this.state)!==t||r?.id!==e.id||r.projectId!==e.projectId||this.setState({gitStatus:n,gitStale:!1})}startTerminalModalPointerInteraction(e,t){if(this.terminalModalMaximized||t.button!==0)return;let n=t.currentTarget;if(!(n instanceof HTMLElement))return;let r=n.closest(`.terminal-modal-frame`);if(!(r instanceof HTMLElement))return;t.preventDefault(),t.stopPropagation();let i=Pg(this.terminalModalBoundsFromFrame(r),this.terminalModalViewport());n.setPointerCapture(t.pointerId),this.terminalModalBounds=i,this.terminalModalPointerInteraction={operation:e,pointerId:t.pointerId,target:n,startClientX:t.clientX,startClientY:t.clientY,bounds:i}}terminalModalBoundsFromFrame(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}terminalModalViewport(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}terminalModalFrameStyle(){let e=this.terminalModalMaximized?void 0:this.terminalModalBounds,t=e===void 0?``:`; left: ${String(e.left)}px; top: ${String(e.top)}px; width: ${String(e.width)}px; height: ${String(e.height)}px`;return`--terminal-modal-opacity: ${String(this.terminalModalOpacity)}%${t};`}finishTerminalModalPointerInteraction(){let e=this.terminalModalPointerInteraction;if(e!==void 0){try{e.target.releasePointerCapture(e.pointerId)}catch{}this.terminalModalPointerInteraction=void 0}}persistTerminalModalPreferences(){Hg({fontSize:this.terminalModalFontSize,opacity:this.terminalModalOpacity})}toggleTerminalTab(){this.terminalTabHidden=!this.terminalTabHidden,$k(this.terminalTabHidden)}toggleInfoTab(){this.infoTabHidden=!this.infoTabHidden,nA(this.infoTabHidden)}renderChatView(e,t){return g`
|
|
6019
|
+
`}mobilePanelBadge(e){let 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){let t=Ck(this.state);return{machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,t.id),host:this.createWorkspaceHost()}}createWorkspaceFiles(e,t){return{readFile:n=>ro.workspaceFile(e.projectId,e.id,n,t),writeFile:async(n,r,i)=>{let a=await ro.writeWorkspaceFile(e.projectId,e.id,n,r,i,t);return this.files.refreshFiles(),a},deleteFile:async n=>{let r=await ro.deleteWorkspaceFile(e.projectId,e.id,n,t);return this.files.refreshFiles(),r},moveFile:async(n,r,i)=>{let a=await ro.moveWorkspaceFile(e.projectId,e.id,n,r,i,t);return this.files.refreshFiles(),a}}}createWorkspaceHost(){return{requestRender:()=>{this.requestUpdate()}}}createWorkspacePanelContext(e){let t=Ck(this.state),n=t.id,r=i=>{let a=this.terminalCommandRunsForOrigin(i,n);return gh({machine:t,workspace:e,state:this.state,files:this.createWorkspaceFiles(e,n),prompt:this.createPromptEditor(),terminal:{open:t=>{this.openRuntimeTerminal(n,e,t)},runCommand:t=>a.runCommand({...t,workspace:e})},openTerminal:t=>{this.openRuntimeTerminal(n,e,t)},host:this.createWorkspaceHost(),piWebUiUnstable:{terminalCommandRuns:a},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:xo(e.effectiveConfig,this.workspaceUploadDefaultFolder),onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:e=>{this.files.expandDir(e)},onSelectFile:e=>{this.files.selectFile(e)},onStartWorkspaceUpload:(e,t)=>this.files.startWorkspaceUpload(e,t),onCancelWorkspaceUpload:e=>{this.files.cancelWorkspaceUpload(e)},onClearWorkspaceUpload:e=>{this.files.clearWorkspaceUpload(e)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:e=>{this.git.selectDiff(e)},onSelectTerminal:(e,t)=>{this.selectTerminal(e,t)}},r)};return r(`core`)}getActions(){return xg(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.toggle-terminal-tab`,title:this.terminalTabHidden?`Show Terminal Tab`:`Hide Terminal Tab`,description:this.terminalTabHidden?`Show the terminal tab in the workspace panel`:`Hide the terminal tab from the workspace panel`,group:`View`,run:()=>{this.toggleTerminalTab()}},{id:`app.layout.toggle-info-tab`,title:this.infoTabHidden?`Show Info Tab`:`Hide Info Tab`,description:this.infoTabHidden?`Show the info tab in the workspace panel`:`Hide the info tab from the workspace panel`,group:`View`,run:()=>{this.toggleInfoTab()}},{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 WEBUI plugins`,()=>$m())}async loadPluginsForSelectedMachine(){let 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;let t=this.machinePluginLoadPromises.get(e.id);if(t!==void 0)return t;let n=this.registerExternalPlugins(`PI WEBUI plugins from ${e.name}`,()=>$m(`api/machines/${encodeURIComponent(e.id)}/pi-webui-plugins/manifest.json`,{machineId:e.id,shouldLoadPlugin:e=>this.plugins.shouldLoadRemotePlugin(e.id,e.machineSpecific)})).then(t=>{t&&this.loadedMachinePluginIds.add(e.id)}).finally(()=>{this.machinePluginLoadPromises.delete(e.id)});this.machinePluginLoadPromises.set(e.id,n),await n}async registerExternalPlugins(e,t){try{let e=await t();for(let t of e)try{this.plugins.register(t)}catch(e){console.warn(`Failed to register PI WEBUI plugin ${t.id}`,e)}return this.applyPreferredTheme(!1),this.requestUpdate(),!0}catch(t){return console.warn(`Failed to load ${e}`,t),!1}}createPromptEditor(){return{insertText:e=>{let t=this.promptEditor?.view;if(!t)return;t.hasFocus||t.focus();let n=t.state.selection.main;t.dispatch({changes:{from:n.from,to:n.to,insert:e},selection:{anchor:n.from+e.length}})},getText:()=>this.promptEditor?.view?.state.doc.toString()??``,getSelection:()=>{let e=this.promptEditor?.view;if(!e)return null;let t=e.state.selection.main;return t.empty?null:{start:t.from,end:t.to,text:e.state.sliceDoc(t.from,t.to)}}}}createPluginRuntimeContext(){let e=t=>hh({state:this.state,prompt:this.createPromptEditor(),piWebUiUnstable:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t),openSettings:e=>{this.openSettings(e)}},openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.focusChatComposer()},addProject:()=>{this.openProjectDialog()},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:e=>{this.selectMainView(e)},selectWorkspaceTool:e=>{this.openWorkspaceTool(e)},openTerminal:e=>{this.openTerminal(e)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),refreshAppData:()=>this.refreshAppData(),checkForPiWebUiUpdates:()=>this.piWebUiStatusController.checkForUpdates(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:e=>this.deleteWorkspace(e),startSession:()=>this.withChatScrollTransition(()=>this.startSessionAndOpenChat()),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(!Id(e)){this.setState({error:`Only secondary Git worktrees can be deleted`});return}if(Op(this.state,e))return;let t=e.branch??e.label;if(!confirm(`Delete workspace ${t}?\n\nThis will run git worktree remove and delete:\n${e.path}\n\nThe Git branch will not be deleted.`))return;let n=R(this.state);try{let t=await ro.deleteWorkspace(e.projectId,e.id,n);if(R(this.state)!==n)return;this.recordWorkspaceDeletionRun(t,n);let r=await this.workspaceForCommandRun(t);if(R(this.state)!==n)return;r!==void 0&&this.openRuntimeTerminal(n,r,{terminalId:t.terminalId})}catch(e){R(this.state)===n&&this.setState({error:`Failed to start workspace deletion: ${Lk(e)}`})}}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(t=>t.id===e.workspaceId)}recordWorkspaceDeletionRun(e,t){if(R(this.state)!==t)return;let n=kp(e);n!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[n]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;let e=R(this.state),t=this.state.selectedProject;if(t===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{let n=await this.terminalCommandRunsForOrigin(`core`,e).listCommandRuns(Tp(t.id));if(R(this.state)!==e)return;let r=Ep(n);this.setState({workspaceDeletionRuns:r});for(let t of Object.values(r))Ap(t)||await this.handleCompletedWorkspaceDeletionRun(t,e)}catch(e){console.warn(`Failed to refresh workspace deletion runs`,e)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){let e=Object.values(this.state.workspaceDeletionRuns).some(Ap);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=R(this.state)){if(R(this.state)!==t)return;let n=Fk(t,e.id);if(this.handledWorkspaceDeletionRunIds.has(n))return;let r=kp(e);if(r!==void 0){if(this.handledWorkspaceDeletionRunIds.add(n),e.status===`succeeded`){if(await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,r),R(this.state)!==t)return;this.setState({workspaceDeletionRuns:Rk(this.state.workspaceDeletionRuns,r)}),this.updateWorkspaceDeletionPolling();return}e.status===`failed`&&(this.setState({error:`Workspace deletion failed. See terminal output.`}),this.updateWorkspaceDeletionPolling())}}openProjectBrowser(e){this.projectBrowserRestoreFocus=e,this.projectBrowserOpen=!0}closeProjectBrowser(e={}){let t=e.restoreFocus===!0?this.projectBrowserRestoreFocus:void 0;this.projectBrowserRestoreFocus=void 0,this.projectBrowserOpen=!1,t!==void 0&&this.updateComplete.then(()=>{t()})}selectProjectFromBrowser(e){this.closeProjectBrowser(),this.selectNavigationItem(`projects`,`workspaces`,()=>this.workspaces.selectProject(e))}addProjectFromBrowser(){this.closeProjectBrowser(),this.openProjectDialog()}openProjectDialog(){this.setState({projectDialogOpen:!0})}openMachineDialog(){this.setState({machineDialogOpen:!0,error:``})}async submitMachineDialog(e){await this.machines.addMachine(e)!==void 0&&(this.setState({machineDialogOpen:!1}),this.schedulePiWebUiStatusRefresh())}async removeMachine(e=this.state.selectedMachine){if(e===void 0||e.kind===`local`||!window.confirm(`Remove ${e.name}?\n\nThis only removes it from this PI WEBUI gateway.`))return;let t=this.state.selectedMachine?.id===e.id;t&&this.rememberCurrentMachineNavigation();let n=await this.machines.deleteMachine(e,{selectFallback:!t});this.state.machines.some(t=>t.id===e.id)||this.machineNavigation.forget(e.id),t&&n!==void 0&&await this.selectMachineWithMemory(n,{rememberCurrent:!1})}openSelectedMachine(){let 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=>{let n=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${n}`})})}async openModelDialog(){let e=await this.sessions.listModels(),t=this.state.status?.model?.provider,n=this.state.status?.model?.id,r=[...e].sort((e,t)=>{let n=e.provider??``,r=t.provider??``;return n===r?(e.id??``).localeCompare(t.id??``):n.localeCompare(r)});this.setState({modelDialog:{title:`Select Model`,...t!==void 0&&n!==void 0?{selectedValue:`${t}/${n}`}:{},options:r.map(e=>{let r=e.provider??``,i=e.id??``,a=r===t&&i===n;return{value:`${r}/${i}`,label:i+(a?` ✓ current`:``),...r===``?{}:{group:r}}})}})}async pickModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openStarterModelDialog(){let e=this.starterSessionDefaults;if(e===void 0)return;let t=e.model?.provider,n=e.model?.id,r=[...e.models].sort((e,t)=>{let n=e.provider??``,r=t.provider??``;return n===r?(e.id??``).localeCompare(t.id??``):n.localeCompare(r)});this.setState({modelDialog:{title:`Select Default Model`,source:`starter`,...t!==void 0&&n!==void 0?{selectedValue:`${t}/${n}`}:{},options:r.map(e=>{let r=e.provider??``,i=e.id??``,a=r===t&&i===n;return{value:`${r}/${i}`,label:i+(a?` ✓ current`:``),...r===``?{}:{group:r}}})}})}async pickStarterModel(e){this.setState({modelDialog:void 0});let t=e.indexOf(`/`);t<=0||await this.updateStarterSessionDefaults({model:{provider:e.slice(0,t),modelId:e.slice(t+1)}})}openThemeDialog(){let e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),n=t.selectedTheme?.id,r=this.themePreference.auto?mk:pk;this.setState({themeDialog:{title:`Select Theme`,selectedValue:n===void 0?r:`${hk}${n}`,options:[{value:r,label:`Auto ${this.themePreference.auto?`✓ on`:`off`}`,description:this.autoThemeDescription(t)},...e.map(e=>({value:`${hk}${e.id}`,label:this.themeOptionLabel(e,n),description:this.themeOptionDescription(e)}))]}})}pickTheme(e){if(this.setState({themeDialog:void 0}),e===pk||e===mk){let t=this.resolveCurrentThemePreference().selectedTheme?.id;if(t===void 0)return;this.themePreference={themeId:t,auto:e===pk},this.applyPreferredTheme(!0);return}if(!e.startsWith(hk))return;let t=e.slice(6),n=this.plugins.getThemes().find(e=>e.id===t);n!==void 0&&(this.themePreference={themeId:n.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){let t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,mp(t),e&&pp(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return hp({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return _p(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){let n=[...e.id===t?[`selected`]:[],...e.id===this.activeThemeId&&e.id!==t?[`active`]:[]];return n.length===0?e.name:`${e.name} ✓ ${n.join(` · `)}`}themeOptionDescription(e){let 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(){let e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??`off`;this.setState({thinkingDialog:{title:`Select Thinking Level`,selectedValue:t,options:e.map(e=>{let n=Kk(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.sessions.setThinkingLevel(e)}openStarterThinkingDialog(){let e=this.starterSessionDefaults;if(e===void 0)return;let t=e.thinkingLevel;this.setState({thinkingDialog:{title:`Select Default Thinking Level`,source:`starter`,selectedValue:t,options:e.thinkingLevels.map(e=>{let n=Kk(e);return{value:e,label:`${e}${e===t?` ✓ current`:``}`,...n===void 0?{}:{description:n}}})}})}async pickStarterThinking(e){this.setState({thinkingDialog:void 0}),e!==``&&await this.updateStarterSessionDefaults({thinkingLevel:e})}async updateStarterSessionDefaults(e){let t=this.state.selectedWorkspace;if(t===void 0)return;let n=R(this.state);try{let r=await io.updateSessionDefaults(t.path,e,n);if(R(this.state)!==n||this.state.selectedWorkspace?.id!==t.id)return;this.starterSessionDefaults=r}catch(e){R(this.state)===n&&this.state.selectedWorkspace?.id===t.id&&this.setState({error:String(e)})}}sendPrompt(e,t,n,r){!(n!==void 0&&n.length>0)&&t===void 0&&this.auth.handleSlashCommand(e)||this.sessions.send(e,t,n,r)}applyGitUpdateManagerStatus(e,t,n){let r=this.state.selectedWorkspace;R(this.state)!==t||r?.id!==e.id||r.projectId!==e.projectId||this.setState({gitStatus:n,gitStale:!1})}startTerminalModalPointerInteraction(e,t){if(this.terminalModalMaximized||t.button!==0)return;let n=t.currentTarget;if(!(n instanceof HTMLElement))return;let r=n.closest(`.terminal-modal-frame`);if(!(r instanceof HTMLElement))return;t.preventDefault(),t.stopPropagation();let i=Pg(this.terminalModalBoundsFromFrame(r),this.terminalModalViewport());n.setPointerCapture(t.pointerId),this.terminalModalBounds=i,this.terminalModalPointerInteraction={operation:e,pointerId:t.pointerId,target:n,startClientX:t.clientX,startClientY:t.clientY,bounds:i}}terminalModalBoundsFromFrame(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t,top:n,width:r,height:i}}terminalModalViewport(){return typeof window>`u`?{width:0,height:0}:{width:window.innerWidth,height:window.innerHeight}}terminalModalFrameStyle(){let e=this.terminalModalMaximized?void 0:this.terminalModalBounds,t=e===void 0?``:`; left: ${String(e.left)}px; top: ${String(e.top)}px; width: ${String(e.width)}px; height: ${String(e.height)}px`;return`--terminal-modal-opacity: ${String(this.terminalModalOpacity)}%${t};`}finishTerminalModalPointerInteraction(){let e=this.terminalModalPointerInteraction;if(e!==void 0){try{e.target.releasePointerCapture(e.pointerId)}catch{}this.terminalModalPointerInteraction=void 0}}persistTerminalModalPreferences(){Hg({fontSize:this.terminalModalFontSize,opacity:this.terminalModalOpacity})}toggleTerminalTab(){this.terminalTabHidden=!this.terminalTabHidden,Hk(this.terminalTabHidden)}toggleInfoTab(){this.infoTabHidden=!this.infoTabHidden,Gk(this.infoTabHidden)}renderChatView(e,t){return g`
|
|
6036
6020
|
<chat-view .sessionId=${t.id} .sessionInfo=${t} .messages=${e.messages} .messageStart=${e.messagePageStart} .messageEnd=${e.messagePageEnd} .messageTotal=${e.messagePageTotal} .hasMore=${e.messagePageStart>0} .loadingMore=${e.isLoadingEarlierMessages} .isSendingPrompt=${e.sendingPrompts[t.id]===!0} .isCompacting=${e.status?.isCompacting===!0} .pendingMessageCount=${e.status?.pendingMessageCount??0} .clientQueuedMessages=${e.clientQueuedSessionMessages[t.id]??[]} .status=${e.status} .warningCount=${this.sessionWarningVisibility.warningCount} .warningsExpanded=${this.sessionWarningVisibility.warningCount>0&&!this.sessionWarningVisibility.collapsed} .onToggleWarnings=${this.handleToggleWarnings} .activity=${e.activity} .notificationInbox=${cd(e.selectedNotificationInbox)} .canClearServerQueue=${this.canClearServerQueue()} .onClearServerQueue=${this.handleClearServerQueue} .canMessageActions=${this.canMessageActions()&&t.archived!==!0} .onEditFromHere=${this.handleEditFromHere} .onForkFromHere=${this.handleForkFromHere} .onDismissWarning=${this.handleDismissWarning} .onDismissNotification=${this.handleDismissNotification} .onDismissAllNotifications=${this.handleDismissAllNotifications} .warningsVisible=${!this.sessionWarningVisibility.collapsed} .onLoadMore=${()=>this.withChatPrependTransition(()=>this.sessions.loadEarlierMessages())}></chat-view>
|
|
6037
6021
|
`}renderContextBar(){return this.appShell.isMobileNavigationLayout?g`
|
|
6038
6022
|
<app-context-bar
|
|
@@ -6051,7 +6035,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6051
6035
|
.selectedView=${this.state.mainView}
|
|
6052
6036
|
.onSelect=${e=>{this.selectMainView(e)}}
|
|
6053
6037
|
></app-mobile-main-tabs>
|
|
6054
|
-
`}mobileMainTabs(){let e=
|
|
6038
|
+
`}mobileMainTabs(){let e=X_(this.state.sessions,this.unreadSessionIds,{statuses:this.state.sessionStatuses,activities:this.state.sessionActivities,sending:this.state.sendingPrompts});return[{id:`navigation`,label:`Sessions`,icon:`navigation`,className:`navigation-tab`,...e===0?{}:{badge:e,badgeLabel:`${String(e)} unread`,badgeTone:`unread`}},{id:`chat`,label:`Chat`,icon:`chat`},...this.visibleWorkspacePanels().map(e=>{let t=e.icon??this.mobilePanelIcon(e);return{id:e.id,label:e.title,...t===void 0?{}:{icon:t},badge:this.mobilePanelBadge(e)}})]}renderAppRefresh(){return g`<app-refresh-control .onReload=${()=>{this.hardReloadApp()}}></app-refresh-control>`}renderTerminalModal(){let e=this.state,t=R(e);return g`
|
|
6055
6039
|
<div
|
|
6056
6040
|
class="terminal-modal-backdrop"
|
|
6057
6041
|
role="dialog"
|
|
@@ -6132,7 +6116,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6132
6116
|
<aside id="navigation-panel">
|
|
6133
6117
|
<activity-rail
|
|
6134
6118
|
.onOpenTerminal=${this.handleOpenTerminalFromRail}
|
|
6135
|
-
.onOpenBrowser=${this.handleOpenBrowserFromRail}
|
|
6136
6119
|
.onOpenGitUpdateManager=${this.handleOpenGitUpdateManagerFromRail}
|
|
6137
6120
|
.onOpenTheme=${this.handleOpenThemeFromRail}
|
|
6138
6121
|
.terminalCount=${this.state.activeTerminalCount}
|
|
@@ -6166,6 +6149,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6166
6149
|
${this.renderWorkspacePanel()}
|
|
6167
6150
|
${e.actionPaletteOpen?g`<action-palette .actions=${this.getActions()} .onRun=${e=>{this.setState({actionPaletteOpen:!1}),this.runAction(e)}} .onCancel=${()=>{this.setState({actionPaletteOpen:!1})}}></action-palette>`:null}
|
|
6168
6151
|
${this.renderSessionTreeNavigator(e)}
|
|
6152
|
+
${this.projectBrowserOpen?g`<project-browser-dialog
|
|
6153
|
+
.projects=${e.projects}
|
|
6154
|
+
.selected=${e.selectedProject}
|
|
6155
|
+
.activities=${e.workspaceActivities}
|
|
6156
|
+
.workspacesByProjectId=${e.workspacesByProjectId}
|
|
6157
|
+
.onSelect=${e=>{this.selectProjectFromBrowser(e)}}
|
|
6158
|
+
.onClose=${()=>{this.closeProjectBrowser({restoreFocus:!0})}}
|
|
6159
|
+
.onAdd=${()=>{this.addProjectFromBrowser()}}
|
|
6160
|
+
.onCloseProject=${e=>this.projects.closeProject(e.id)}
|
|
6161
|
+
></project-browser-dialog>`:null}
|
|
6169
6162
|
${this.historyWindow===void 0?null:g`<session-history-window .machineId=${this.historyWindow.machineId} .session=${this.historyWindow.session} .onClose=${()=>{this.historyWindow=void 0}}></session-history-window>`}
|
|
6170
6163
|
${e.projectDialogOpen?g`<project-dialog .machineId=${R(e)} .onSubmit=${(e,t)=>this.projects.addProject(e,t)} .onCancel=${()=>{this.setState({projectDialogOpen:!1})}}></project-dialog>`:null}
|
|
6171
6164
|
${e.machineDialogOpen?g`<machine-dialog .error=${e.error} .onSubmit=${e=>this.submitMachineDialog(e)} .onCancel=${()=>{this.setState({machineDialogOpen:!1})}}></machine-dialog>`:null}
|
|
@@ -6176,9 +6169,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
6176
6169
|
${this.systemPromptDialogOpen&&e.selectedSession!==void 0?g`<system-prompt-dialog .machine=${e.selectedMachine} .session=${e.selectedSession} .onClose=${()=>{this.systemPromptDialogOpen=!1}}></system-prompt-dialog>`:null}
|
|
6177
6170
|
${e.themeDialog===void 0?null:g`<command-picker title=${e.themeDialog.title} .options=${e.themeDialog.options} .selectedValue=${e.themeDialog.selectedValue} .onPick=${e=>{this.pickTheme(e)}} .onCancel=${()=>{this.setState({themeDialog:void 0})}}></command-picker>`}
|
|
6178
6171
|
${e.authDialog===void 0?null:g`<auth-dialog .state=${e.authDialog} .onChooseMethod=${e=>{this.auth.chooseLoginMethod(e)}} .onSelectProvider=${(e,t)=>{this.auth.selectLoginProvider(e,t)}} .onApiKeyInput=${e=>{this.auth.updateApiKey(e)}} .onSaveApiKey=${()=>{this.auth.saveApiKey()}} .onLogoutProvider=${e=>{this.auth.logoutProvider(e)}} .onOAuthInput=${e=>{this.auth.updateOAuthInput(e)}} .onOAuthRespond=${e=>{this.auth.respondOAuth(e)}} .onOAuthCancel=${()=>{this.auth.cancelOAuth()}} .onCancel=${()=>{this.auth.closeDialog()}}></auth-dialog>`}
|
|
6179
|
-
${this.browserPanelOpen?g`<browser-panel .onClose=${this.handleCloseBrowserPanel}></browser-panel>`:null}
|
|
6180
6172
|
${n===void 0?null:g`<git-update-manager-panel .workspace=${n} .machineId=${R(e)} .onStatusChange=${t=>{this.applyGitUpdateManagerStatus(n,R(e),t)}} .onClose=${this.handleCloseGitUpdateManagerPanel}></git-update-manager-panel>`}
|
|
6181
6173
|
${this.terminalModalOpen?this.renderTerminalModal():null}
|
|
6182
6174
|
${this.settingsSection===void 0?null:g`<settings-dialog .section=${this.settingsSection} .machine=${e.selectedMachine} .machineRuntime=${this.selectedMachineRuntime()} .actions=${this.getDefaultActions()} .onNavigate=${e=>{this.navigateSettings(e)}} .onClose=${()=>{this.closeSettings()}} .onConfigSaved=${e=>{this.applyClientConfig(e)}} .onRefreshMachineRuntime=${async e=>{await this.machines.refreshMachineRuntime(e)}}></settings-dialog>`}
|
|
6183
6175
|
</div>
|
|
6184
|
-
`}static{this.styles=Gp}};B([S()],$.prototype,`state`,void 0),B([C(`chat-view`)],$.prototype,`chatView`,void 0),B([C(`prompt-editor`)],$.prototype,`promptEditor`,void 0),B([C(`app-navigation-panel`)],$.prototype,`navigationPanel`,void 0),B([C(`#navigation-panel`)],$.prototype,`navigationPanelFrame`,void 0),B([C(`#workspace-panel`)],$.prototype,`workspacePanelFrame`,void 0),B([S()],$.prototype,`unreadSessionIds`,void 0),B([S()],$.prototype,`activeThemeId`,void 0),B([S()],$.prototype,`isRefreshingApp`,void 0),B([S()],$.prototype,`sessionCleanupDialog`,void 0),B([S()],$.prototype,`historyWindow`,void 0),B([S()],$.prototype,`starterSessionDefaults`,void 0),B([S()],$.prototype,`modelsConfigDialogOpen`,void 0),B([S()],$.prototype,`
|
|
6176
|
+
`}static{this.styles=Gp}};B([S()],$.prototype,`state`,void 0),B([C(`chat-view`)],$.prototype,`chatView`,void 0),B([C(`prompt-editor`)],$.prototype,`promptEditor`,void 0),B([C(`app-navigation-panel`)],$.prototype,`navigationPanel`,void 0),B([C(`#navigation-panel`)],$.prototype,`navigationPanelFrame`,void 0),B([C(`#workspace-panel`)],$.prototype,`workspacePanelFrame`,void 0),B([S()],$.prototype,`unreadSessionIds`,void 0),B([S()],$.prototype,`activeThemeId`,void 0),B([S()],$.prototype,`isRefreshingApp`,void 0),B([S()],$.prototype,`sessionCleanupDialog`,void 0),B([S()],$.prototype,`historyWindow`,void 0),B([S()],$.prototype,`starterSessionDefaults`,void 0),B([S()],$.prototype,`modelsConfigDialogOpen`,void 0),B([S()],$.prototype,`projectBrowserOpen`,void 0),B([S()],$.prototype,`skillsConfigDialogOpen`,void 0),B([S()],$.prototype,`pluginsConfigDialogOpen`,void 0),B([S()],$.prototype,`systemPromptDialogOpen`,void 0),B([S()],$.prototype,`gitUpdateManagerPanelOpen`,void 0),B([S()],$.prototype,`terminalModalOpen`,void 0),B([S()],$.prototype,`terminalModalBounds`,void 0),B([S()],$.prototype,`terminalModalMaximized`,void 0),B([S()],$.prototype,`terminalModalFontSize`,void 0),B([S()],$.prototype,`terminalModalOpacity`,void 0),B([S()],$.prototype,`terminalTabHidden`,void 0),B([S()],$.prototype,`infoTabHidden`,void 0),B([S()],$.prototype,`railOrder`,void 0),B([S()],$.prototype,`settingsSection`,void 0),B([S()],$.prototype,`shortcutConfig`,void 0),B([S()],$.prototype,`workspaceUploadDefaultFolder`,void 0),$=B([b(`pi-webui-app`)],$);function Sk(){let e=new fh;return e.register({id:`core`,plugin:Um}),e.register({id:`themes`,plugin:qm}),e}function Ck(e){let t=e.selectedMachine;return t===void 0?{id:`local`,name:`local`,kind:`local`}:{id:t.id,name:t.name,kind:t.kind}}function wk(e,t){return JSON.stringify([e,t.id,t.cwd])}function Tk(e){let t=e.selectedSession;return t===void 0?void 0:wk(R(e),t)}function Ek(e,t){return e.machines!==t.machines||e.machineRuntimes!==t.machineRuntimes}function Dk(e,t){return e.machines!==t.machines||e.machineStatuses!==t.machineStatuses||(e.selectedMachine?.id??`local`)!==(t.selectedMachine?.id??`local`)}function Ok(e,t){return kk(e,t)}function kk(e,t){if(e.kind===`local`)return!0;let n=t?.status??e.status;return n===void 0||n===`unknown`||n===`online`}function Ak(e,t){return Object.entries(t).some(([t,n])=>Reflect.get(e,t)!==n)}function jk(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function Mk(e){return Vo(e.status,e.activity)}function Nk(e){return e.type===`terminal.created`||e.type===`terminal.exited`||e.type===`terminal.closed`}function Pk(){return{}}function Fk(e,t){return JSON.stringify([e,t])}function Ik(e){return dk[Math.min(e,dk.length-1)]??3e4}function Lk(e){return e instanceof Error?e.message:String(e)}function Rk(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function zk(){return new Promise(e=>requestAnimationFrame(()=>{e()}))}var Bk=`pi-webui:terminal-tab-hidden`;function Vk(){try{let e=typeof localStorage>`u`?void 0:localStorage;return e!==void 0&&e.getItem(Bk)===`true`}catch{return!1}}function Hk(e){try{let t=typeof localStorage>`u`?void 0:localStorage;if(t===void 0)return;e?t.setItem(Bk,`true`):t.removeItem(Bk)}catch{}}var Uk=`pi-webui:info-tab-hidden`;function Wk(){try{let e=typeof localStorage>`u`?void 0:localStorage;return e!==void 0&&e.getItem(Uk)===`true`}catch{return!1}}function Gk(e){try{let t=typeof localStorage>`u`?void 0:localStorage;if(t===void 0)return;e?t.setItem(Uk,`true`):t.removeItem(Uk)}catch{}}function Kk(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{y as a,b as i,C as n,g as o,x as r,h as s,B as t};
|