@jmfederico/pi-web 1.202605.13 → 1.202605.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +125 -9
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{CodeViewer-ncgSvOQM.js → CodeViewer-kpPA8xEx.js} +1 -1
- package/dist/client/assets/TerminalPanel-Do-9K9_u.js +122 -0
- package/dist/client/assets/index-DLWwr-NN.js +1307 -0
- package/dist/client/index.html +1 -1
- package/dist/server/sessions/piSessionService.js +122 -22
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/package.json +1 -1
- package/dist/client/assets/TerminalPanel-DjuVNsp5.js +0 -75
- package/dist/client/assets/index-CDGTKzLD.js +0 -1239
|
@@ -0,0 +1,1307 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-kpPA8xEx.js","assets/vendor-editor-core-B4Sq6exx.js","assets/vendor-editor-languages-DznYbTkJ.js","assets/vendor-editor-legacy-B4QLsWF8.js","assets/TerminalPanel-Do-9K9_u.js","assets/vendor-terminal-DjQ08hXu.js","assets/vendor-terminal-DDGTF8rc.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{Q as Hi,w as Pe,J as Wt,R as ro,S as oo,G as no,U as ao,V as lo,A as co,W as po,X as ho,Y as uo,Z as Ui,x as Vi,_ as fo}from"./vendor-editor-core-B4Sq6exx.js";import{m as mo,i as go,d as vo}from"./vendor-editor-languages-DznYbTkJ.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const n of o.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&s(n)}).observe(document,{childList:!0,subtree:!0});function i(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(r){if(r.ep)return;r.ep=!0;const o=i(r);fetch(r.href,o)}})();const lt=globalThis,li=lt.ShadowRoot&&(lt.ShadyCSS===void 0||lt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ci=Symbol(),Gi=new WeakMap;let Ys=class{constructor(t,i,s){if(this._$cssResult$=!0,s!==ci)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o;const i=this.t;if(li&&t===void 0){const s=i!==void 0&&i.length===1;s&&(t=Gi.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Gi.set(i,t))}return t}toString(){return this.cssText}};const bo=e=>new Ys(typeof e=="string"?e:e+"",void 0,ci),V=(e,...t)=>{const i=e.length===1?e[0]:t.reduce((s,r,o)=>s+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[o+1],e[0]);return new Ys(i,e,ci)},wo=(e,t)=>{if(li)e.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(const i of t){const s=document.createElement("style"),r=lt.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=i.cssText,e.appendChild(s)}},Ki=li?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let i="";for(const s of t.cssRules)i+=s.cssText;return bo(i)})(e):e;const{is:yo,defineProperty:xo,getOwnPropertyDescriptor:ko,getOwnPropertyNames:So,getOwnPropertySymbols:$o,getPrototypeOf:Po}=Object,Ct=globalThis,Qi=Ct.trustedTypes,To=Qi?Qi.emptyScript:"",Co=Ct.reactiveElementPolyfillSupport,He=(e,t)=>e,ut={toAttribute(e,t){switch(t){case Boolean:e=e?To:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=e!==null;break;case Number:i=e===null?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch{i=null}}return i}},di=(e,t)=>!yo(e,t),Ji={attribute:!0,type:String,converter:ut,reflect:!1,useDefault:!1,hasChanged:di};Symbol.metadata??=Symbol("metadata"),Ct.litPropertyMetadata??=new WeakMap;let Ie=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,i=Ji){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(t,i),!i.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(t,s,i);r!==void 0&&xo(this.prototype,t,r)}}static getPropertyDescriptor(t,i,s){const{get:r,set:o}=ko(this.prototype,t)??{get(){return this[i]},set(n){this[i]=n}};return{get:r,set(n){const a=r?.call(this);o?.call(this,n),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ji}static _$Ei(){if(this.hasOwnProperty(He("elementProperties")))return;const t=Po(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(He("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(He("properties"))){const i=this.properties,s=[...So(i),...$o(i)];for(const r of s)this.createProperty(r,i[r])}const t=this[Symbol.metadata];if(t!==null){const i=litPropertyMetadata.get(t);if(i!==void 0)for(const[s,r]of i)this.elementProperties.set(s,r)}this._$Eh=new Map;for(const[i,s]of this.elementProperties){const r=this._$Eu(i,s);r!==void 0&&this._$Eh.set(r,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const i=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const r of s)i.unshift(Ki(r))}else t!==void 0&&i.push(Ki(t));return i}static _$Eu(t,i){const s=i.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,i=this.constructor.elementProperties;for(const s of i.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return wo(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,i,s){this._$AK(t,s)}_$ET(t,i){const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(r!==void 0&&s.reflect===!0){const o=(s.converter?.toAttribute!==void 0?s.converter:ut).toAttribute(i,s.type);this._$Em=t,o==null?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,i){const s=this.constructor,r=s._$Eh.get(t);if(r!==void 0&&this._$Em!==r){const o=s.getPropertyOptions(r),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:ut;this._$Em=r;const a=n.fromAttribute(i,o.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(t,i,s,r=!1,o){if(t!==void 0){const n=this.constructor;if(r===!1&&(o=this[t]),s??=n.getPropertyOptions(t),!((s.hasChanged??di)(o,i)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,i,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,i,{useDefault:s,reflect:r,wrapped:o},n){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??i??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(i=void 0),this._$AL.set(t,i)),r===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s){const{wrapped:n}=o,a=this[r];n!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,o,a)}}let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(i)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(i)}willUpdate(t){}_$AE(t){this._$EO?.forEach(i=>i.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(i=>this._$ET(i,this[i])),this._$EM()}updated(t){}firstUpdated(t){}};Ie.elementStyles=[],Ie.shadowRootOptions={mode:"open"},Ie[He("elementProperties")]=new Map,Ie[He("finalized")]=new Map,Co?.({ReactiveElement:Ie}),(Ct.reactiveElementVersions??=[]).push("2.1.2");const pi=globalThis,Zi=e=>e,ft=pi.trustedTypes,Xi=ft?ft.createPolicy("lit-html",{createHTML:e=>e}):void 0,er="$lit$",pe=`lit$${Math.random().toFixed(9).slice(2)}$`,tr="?"+pe,Io=`<${tr}>`,we=document,Ue=()=>we.createComment(""),Ve=e=>e===null||typeof e!="object"&&typeof e!="function",hi=Array.isArray,Ao=e=>hi(e)||typeof e?.[Symbol.iterator]=="function",jt=`[
|
|
3
|
+
\f\r]`,Oe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Yi=/-->/g,es=/>/g,ue=RegExp(`>|${jt}(?:([^\\s"'>=/]+)(${jt}*=${jt}*(?:[^
|
|
4
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ts=/'/g,is=/"/g,ir=/^(?:script|style|textarea|title)$/i,Ro=e=>(t,...i)=>({_$litType$:e,strings:t,values:i}),c=Ro(1),he=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),ss=new WeakMap,ve=we.createTreeWalker(we,129);function sr(e,t){if(!hi(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xi!==void 0?Xi.createHTML(t):t}const Mo=(e,t)=>{const i=e.length-1,s=[];let r,o=t===2?"<svg>":t===3?"<math>":"",n=Oe;for(let a=0;a<i;a++){const l=e[a];let d,u,p=-1,f=0;for(;f<l.length&&(n.lastIndex=f,u=n.exec(l),u!==null);)f=n.lastIndex,n===Oe?u[1]==="!--"?n=Yi:u[1]!==void 0?n=es:u[2]!==void 0?(ir.test(u[2])&&(r=RegExp("</"+u[2],"g")),n=ue):u[3]!==void 0&&(n=ue):n===ue?u[0]===">"?(n=r??Oe,p=-1):u[1]===void 0?p=-2:(p=n.lastIndex-u[2].length,d=u[1],n=u[3]===void 0?ue:u[3]==='"'?is:ts):n===is||n===ts?n=ue:n===Yi||n===es?n=Oe:(n=ue,r=void 0);const g=n===ue&&e[a+1].startsWith("/>")?" ":"";o+=n===Oe?l+Io:p>=0?(s.push(d),l.slice(0,p)+er+l.slice(p)+pe+g):l+pe+(p===-2?a:g)}return[sr(e,o+(e[i]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class Ge{constructor({strings:t,_$litType$:i},s){let r;this.parts=[];let o=0,n=0;const a=t.length-1,l=this.parts,[d,u]=Mo(t,i);if(this.el=Ge.createElement(d,s),ve.currentNode=this.el.content,i===2||i===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(r=ve.nextNode())!==null&&l.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const p of r.getAttributeNames())if(p.endsWith(er)){const f=u[n++],g=r.getAttribute(p).split(pe),v=/([.?@])?(.*)/.exec(f);l.push({type:1,index:o,name:v[2],strings:g,ctor:v[1]==="."?Do:v[1]==="?"?_o:v[1]==="@"?Lo:It}),r.removeAttribute(p)}else p.startsWith(pe)&&(l.push({type:6,index:o}),r.removeAttribute(p));if(ir.test(r.tagName)){const p=r.textContent.split(pe),f=p.length-1;if(f>0){r.textContent=ft?ft.emptyScript:"";for(let g=0;g<f;g++)r.append(p[g],Ue()),ve.nextNode(),l.push({type:2,index:++o});r.append(p[f],Ue())}}}else if(r.nodeType===8)if(r.data===tr)l.push({type:2,index:o});else{let p=-1;for(;(p=r.data.indexOf(pe,p+1))!==-1;)l.push({type:7,index:o}),p+=pe.length-1}o++}}static createElement(t,i){const s=we.createElement("template");return s.innerHTML=t,s}}function Ae(e,t,i=e,s){if(t===he)return t;let r=s!==void 0?i._$Co?.[s]:i._$Cl;const o=Ve(t)?void 0:t._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),o===void 0?r=void 0:(r=new o(e),r._$AT(e,i,s)),s!==void 0?(i._$Co??=[])[s]=r:i._$Cl=r),r!==void 0&&(t=Ae(e,r._$AS(e,t.values),r,s)),t}class Eo{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,r=(t?.creationScope??we).importNode(i,!0);ve.currentNode=r;let o=ve.nextNode(),n=0,a=0,l=s[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new Ee(o,o.nextSibling,this,t):l.type===1?d=new l.ctor(o,l.name,l.strings,this,t):l.type===6&&(d=new Oo(o,this,t)),this._$AV.push(d),l=s[++a]}n!==l?.index&&(o=ve.nextNode(),n++)}return ve.currentNode=we,r}p(t){let i=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class Ee{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,r){this.type=2,this._$AH=A,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return i!==void 0&&t?.nodeType===11&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=Ae(this,t,i),Ve(t)?t===A||t==null||t===""?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==he&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Ao(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==A&&Ve(this._$AH)?this._$AA.nextSibling.data=t:this.T(we.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,r=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Ge.createElement(sr(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(i);else{const o=new Eo(r,this),n=o.u(this.options);o.p(i),this.T(n),this._$AH=o}}_$AC(t){let i=ss.get(t.strings);return i===void 0&&ss.set(t.strings,i=new Ge(t)),i}k(t){hi(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,r=0;for(const o of t)r===i.length?i.push(s=new Ee(this.O(Ue()),this.O(Ue()),this,this.options)):s=i[r],s._$AI(o),r++;r<i.length&&(this._$AR(s&&s._$AB.nextSibling,r),i.length=r)}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t!==this._$AB;){const s=Zi(t).nextSibling;Zi(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}let It=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,r,o){this.type=1,this._$AH=A,this._$AN=void 0,this.element=t,this.name=i,this._$AM=r,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A}_$AI(t,i=this,s,r){const o=this.strings;let n=!1;if(o===void 0)t=Ae(this,t,i,0),n=!Ve(t)||t!==this._$AH&&t!==he,n&&(this._$AH=t);else{const a=t;let l,d;for(t=o[0],l=0;l<o.length-1;l++)d=Ae(this,a[s+l],i,l),d===he&&(d=this._$AH[l]),n||=!Ve(d)||d!==this._$AH[l],d===A?t=A:t!==A&&(t+=(d??"")+o[l+1]),this._$AH[l]=d}n&&!r&&this.j(t)}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Do=class extends It{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===A?void 0:t}},_o=class extends It{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A)}},Lo=class extends It{constructor(t,i,s,r,o){super(t,i,s,r,o),this.type=5}_$AI(t,i=this){if((t=Ae(this,t,i,0)??A)===he)return;const s=this._$AH,r=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==A&&(s===A||r);r&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}};class Oo{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Ae(this,t)}}const Wo={I:Ee},jo=pi.litHtmlPolyfillSupport;jo?.(Ge,Ee),(pi.litHtmlVersions??=[]).push("3.3.2");const No=(e,t,i)=>{const s=i?.renderBefore??t;let r=s._$litPart$;if(r===void 0){const o=i?.renderBefore??null;s._$litPart$=r=new Ee(t.insertBefore(Ue(),o),o,void 0,i??{})}return r._$AI(e),r};const ui=globalThis;let R=class extends Ie{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=No(i,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return he}};R._$litElement$=!0,R.finalized=!0,ui.litElementHydrateSupport?.({LitElement:R});const Fo=ui.litElementPolyfillSupport;Fo?.({LitElement:R});(ui.litElementVersions??=[]).push("4.2.2");const F=e=>(t,i)=>{i!==void 0?i.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const Bo={attribute:!0,type:String,converter:ut,reflect:!1,hasChanged:di},zo=(e=Bo,t,i)=>{const{kind:s,metadata:r}=i;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),o.set(i.name,e),s==="accessor"){const{name:n}=i;return{set(a){const l=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,l,e,!0,a)},init(a){return a!==void 0&&this.C(n,void 0,e,a),a}}}if(s==="setter"){const{name:n}=i;return function(a){const l=this[n];t.call(this,a),this.requestUpdate(n,l,e,!0,a)}}throw Error("Unsupported decorator location: "+s)};function h(e){return(t,i)=>typeof i=="object"?zo(e,t,i):((s,r,o)=>{const n=r.hasOwnProperty(o);return r.constructor.createProperty(o,s),n?Object.getOwnPropertyDescriptor(r,o):void 0})(e,t,i)}function x(e){return h({...e,state:!0,attribute:!1})}const qo=(e,t,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(e,t,i),i);function se(e,t){return(i,s,r)=>{const o=n=>n.renderRoot?.querySelector(e)??null;return qo(i,s,{get(){return o(this)}})}}async function b(e,t,i){const s=new Headers(i?.headers);i?.body!==void 0&&s.set("content-type","application/json");const r=await fetch(e,{...i,headers:s});if(!r.ok){const n=await r.json().catch(()=>({}));throw new Error(Ho(n)??r.statusText)}const o=await r.json();return t(o)}function Ho(e){if(Uo(e))return typeof e.error=="string"?e.error:void 0}function Uo(e){return typeof e=="object"&&e!==null}function Vo(e){return typeof e=="object"&&e!==null}function w(e){if(!Vo(e))throw new Error("Expected object response");return e}function m(e,t){const i=e[t];if(typeof i!="string")throw new Error(`Expected string field: ${t}`);return i}function k(e,t){const i=e[t];if(i!==void 0){if(typeof i!="string")throw new Error(`Expected optional string field: ${t}`);return i}}function K(e,t){const i=e[t];if(typeof i!="number")throw new Error(`Expected number field: ${t}`);return i}function L(e,t){const i=e[t];if(typeof i!="boolean")throw new Error(`Expected boolean field: ${t}`);return i}function O(e){return t=>{if(!Array.isArray(t))throw new Error("Expected array response");return t.map(e)}}function Go(e){if(!Array.isArray(e))throw new Error("Expected array response");return e}function Ko(e,t){if(!Array.isArray(e)||!e.every(i=>typeof i=="string"))throw new Error(`Expected string array field: ${t}`);return e}function Qo(e){if(Array.isArray(e))return{messages:e,start:0,total:e.length};const t=w(e);return{messages:Go(t.messages),start:K(t,"start"),total:K(t,"total")}}function rs(e){const t=w(e);return{id:m(t,"id"),name:m(t,"name"),path:m(t,"path"),createdAt:m(t,"createdAt")}}function Jo(e){const t=w(e),i=k(t,"branch");return{id:m(t,"id"),projectId:m(t,"projectId"),path:m(t,"path"),label:m(t,"label"),...i===void 0?{}:{branch:i},isMain:L(t,"isMain"),isGitRepo:L(t,"isGitRepo"),isGitWorktree:L(t,"isGitWorktree")}}function Jt(e){const t=w(e),i=k(t,"name"),s=k(t,"parentSessionPath"),r=k(t,"archivedAt");return{id:m(t,"id"),path:m(t,"path"),cwd:m(t,"cwd"),...i===void 0?{}:{name:i},created:m(t,"created"),modified:m(t,"modified"),messageCount:K(t,"messageCount"),firstMessage:m(t,"firstMessage"),...s===void 0?{}:{parentSessionPath:s},...t.archived===!0?{archived:!0}:{},...r===void 0?{}:{archivedAt:r}}}function We(e){const t=w(e);return{sessionId:m(t,"sessionId"),isStreaming:L(t,"isStreaming"),isCompacting:L(t,"isCompacting"),isBashRunning:L(t,"isBashRunning"),pendingMessageCount:K(t,"pendingMessageCount"),queuedMessages:t.queuedMessages===void 0?[]:O(Zo)(t.queuedMessages),...y("messageCount",ne(t,"messageCount")),tokens:Xo(t.tokens),cost:K(t,"cost"),...Yo(t.model),...un(t.contextUsage),...y("thinkingLevel",k(t,"thinkingLevel"))}}function Zo(e){const t=w(e),i=m(t,"kind");if(i!=="steer"&&i!=="followUp")throw new Error("Invalid queued message kind");return{kind:i,text:m(t,"text")}}function Xo(e){const t=w(e);return{input:K(t,"input"),output:K(t,"output"),cacheRead:K(t,"cacheRead"),cacheWrite:K(t,"cacheWrite"),total:K(t,"total")}}function rr(e){const t=w(e);return{...y("provider",k(t,"provider")),...y("id",k(t,"id")),...y("name",k(t,"name")),...y("contextWindow",ne(t,"contextWindow")),...y("reasoning",t.reasoning)}}function Yo(e){return e===void 0?{}:{model:rr(e)}}function en(e){const t=w(e);return{models:O(rr)(t.models)}}function tn(e){if(e!=="off"&&e!=="minimal"&&e!=="low"&&e!=="medium"&&e!=="high"&&e!=="xhigh")throw new Error("Invalid thinking level");return e}function sn(e){const t=w(e);return{levels:O(tn)(t.levels)}}function rn(e){if(e!=="oauth"&&e!=="api_key")throw new Error("Invalid auth type");return e}function on(e){if(e!=="stored"&&e!=="runtime"&&e!=="environment"&&e!=="fallback"&&e!=="models_json_key"&&e!=="models_json_command")throw new Error("Invalid auth status source");return e}function nn(e){const t=w(e),i=t.source===void 0?void 0:on(t.source);return{configured:L(t,"configured"),...y("source",i),...y("label",k(t,"label"))}}function an(e){const t=w(e);return{id:m(t,"id"),name:m(t,"name"),authType:rn(t.authType),status:nn(t.status)}}function ln(e){const t=w(e);return{providers:O(an)(t.providers)}}function tt(e){const t=w(e);return{flowId:m(t,"flowId"),providerId:m(t,"providerId"),providerName:m(t,"providerName"),status:cn(t.status),progress:O(s=>{if(typeof s!="string")throw new Error("Expected progress item string");return s})(t.progress),...y("error",k(t,"error")),...y("auth",dn(t.auth)),...y("prompt",pn(t.prompt)),...y("select",hn(t.select))}}function cn(e){if(e!=="running"&&e!=="complete"&&e!=="error"&&e!=="cancelled")throw new Error("Invalid OAuth flow status");return e}function dn(e){if(e===void 0)return;const t=w(e);return{url:m(t,"url"),...y("instructions",k(t,"instructions"))}}function pn(e){if(e===void 0)return;const t=w(e),i=m(t,"kind");if(i!=="prompt"&&i!=="manual")throw new Error("Invalid OAuth prompt kind");return{requestId:m(t,"requestId"),message:m(t,"message"),kind:i,...y("placeholder",k(t,"placeholder")),...t.allowEmpty===!0?{allowEmpty:!0}:{}}}function hn(e){if(e===void 0)return;const t=w(e);return{requestId:m(t,"requestId"),message:m(t,"message"),options:O(nr)(t.options)}}function un(e){if(e===void 0)return{};const t=w(e);return{contextUsage:{tokens:cs(t,"tokens"),contextWindow:K(t,"contextWindow"),percent:cs(t,"percent")}}}function fn(e){const t=w(e),i=m(t,"source");if(i!=="extension"&&i!=="prompt"&&i!=="skill"&&i!=="builtin")throw new Error("Invalid command source");return{name:m(t,"name"),source:i,...y("description",k(t,"description"))}}function or(e){const t=w(e),i=m(t,"kind");if(i!=="tracked"&&i!=="untracked"&&i!=="other")throw new Error("Invalid file kind");return{path:m(t,"path"),kind:i}}function mn(e){const t=w(e);return{path:m(t,"path"),entries:O(gn)(t.entries),scannedAt:m(t,"scannedAt"),truncated:L(t,"truncated")}}function gn(e){const t=w(e),i=m(t,"type");if(i!=="file"&&i!=="directory"&&i!=="symlink")throw new Error("Invalid file tree entry type");return{name:m(t,"name"),path:m(t,"path"),type:i,...y("size",ne(t,"size")),...y("modifiedAt",k(t,"modifiedAt"))}}function vn(e){const t=w(e),i=m(t,"encoding");if(i!=="utf8")throw new Error("Invalid file encoding");return{path:m(t,"path"),...y("language",k(t,"language")),...y("mediaType",bn(t.mediaType)),...y("mimeType",k(t,"mimeType")),encoding:i,size:K(t,"size"),modifiedAt:m(t,"modifiedAt"),content:m(t,"content"),truncated:L(t,"truncated"),binary:L(t,"binary")}}function bn(e){if(e!==void 0){if(e!=="image")throw new Error("Invalid file media type");return e}}function wn(e){const t=w(e);return{isGitRepo:L(t,"isGitRepo"),hash:m(t,"hash"),...y("branch",k(t,"branch")),...y("upstream",k(t,"upstream")),...y("ahead",ne(t,"ahead")),...y("behind",ne(t,"behind")),files:O(yn)(t.files)}}function yn(e){const t=w(e);return{path:m(t,"path"),...y("oldPath",k(t,"oldPath")),index:os(t.index),workingTree:os(t.workingTree)}}function os(e){switch(e){case"unmodified":case"modified":case"added":case"deleted":case"renamed":case"copied":case"untracked":case"ignored":case"conflicted":return e;default:throw new Error("Invalid git file state")}}function xn(e){const t=w(e);return{...y("path",k(t,"path")),staged:L(t,"staged"),hash:m(t,"hash"),diff:m(t,"diff"),truncated:L(t,"truncated")}}function Nt(e){const t=w(e);return{id:m(t,"id"),cwd:m(t,"cwd"),name:m(t,"name"),createdAt:m(t,"createdAt"),exited:L(t,"exited"),...y("exitCode",ne(t,"exitCode")),...y("commandRunId",k(t,"commandRunId"))}}function ct(e){const t=w(e);return{id:m(t,"id"),origin:m(t,"origin"),projectId:m(t,"projectId"),workspaceId:m(t,"workspaceId"),terminalId:m(t,"terminalId"),title:m(t,"title"),command:m(t,"command"),status:kn(t.status),...y("exitCode",ne(t,"exitCode")),createdAt:m(t,"createdAt"),...y("startedAt",k(t,"startedAt")),...y("completedAt",k(t,"completedAt")),metadata:Sn(t.metadata,"metadata")}}function kn(e){if(e!=="queued"&&e!=="running"&&e!=="succeeded"&&e!=="failed")throw new Error("Invalid terminal command run status");return e}function Sn(e,t){const i=w(e);return Object.fromEntries(Object.entries(i).map(([s,r])=>{if(typeof r!="string")throw new Error(`Expected string record field: ${t}.${s}`);return[s,r]}))}function $n(e){const t=w(e);return{cwd:m(t,"cwd"),hasSessionActivity:L(t,"hasSessionActivity"),hasTerminalActivity:L(t,"hasTerminalActivity"),updatedAt:m(t,"updatedAt")}}function Pn(e){const t=w(e);return{workspaces:O($n)(t.workspaces),generatedAt:m(t,"generatedAt")}}function Tn(e){const t=w(e);return{packageName:m(t,"packageName"),generatedAt:m(t,"generatedAt"),components:Cn(t.components),release:An(t.release),commands:Rn(t.commands),messages:O(Mn)(t.messages)}}function Cn(e){const t=w(e);return{web:ns(t.web),sessiond:ns(t.sessiond)}}function ns(e){const t=w(e);return{component:En(t.component),label:m(t,"label"),...y("runtimeVersion",k(t,"runtimeVersion")),...y("installedVersion",k(t,"installedVersion")),stale:L(t,"stale"),available:L(t,"available"),...y("installation",In(t.installation)),...y("error",k(t,"error"))}}function In(e){if(e===void 0)return;const t=w(e),i=m(t,"kind");if(i!=="pi-package"&&i!=="npm-global"&&i!=="local"&&i!=="unknown")throw new Error("Invalid PI WEB installation kind");const s=t.scope;if(s!==void 0&&s!=="user"&&s!=="project")throw new Error("Invalid PI WEB installation scope");return{kind:i,...y("path",k(t,"path")),...y("source",k(t,"source")),...s===void 0?{}:{scope:s},...y("npmRoot",k(t,"npmRoot"))}}function An(e){const t=w(e);return{packageName:m(t,"packageName"),...y("latestVersion",k(t,"latestVersion")),updateAvailable:L(t,"updateAvailable"),...y("checkedAt",k(t,"checkedAt")),...t.skipped===!0?{skipped:!0}:{},...y("error",k(t,"error"))}}function Rn(e){const t=w(e);return{update:m(t,"update"),restart:m(t,"restart"),restartSystemd:m(t,"restartSystemd"),restartDev:m(t,"restartDev")}}function Mn(e){const t=w(e);return{id:m(t,"id"),severity:Dn(t.severity),title:m(t,"title"),body:m(t,"body"),...y("command",k(t,"command"))}}function En(e){if(e!=="web"&&e!=="sessiond")throw new Error("Invalid PI WEB service component");return e}function Dn(e){if(e!=="info"&&e!=="warning"&&e!=="error")throw new Error("Invalid PI WEB status severity");return e}function as(e){const t=w(e),i=m(t,"type");if(i==="unsupported")return{type:i,message:m(t,"message")};if(i==="select")return{type:i,requestId:m(t,"requestId"),title:m(t,"title"),options:O(nr)(t.options)};if(i==="done")return{type:i,...y("message",k(t,"message")),..._n(t.session),...y("promptDraft",k(t,"promptDraft"))};throw new Error("Invalid command result type")}function nr(e){const t=w(e);return{value:m(t,"value"),label:m(t,"label"),...y("description",k(t,"description"))}}function _n(e){return e===void 0?{}:{session:Jt(e)}}function it(e){if(w(e).accepted!==!0)throw new Error("Expected accepted response");return{accepted:!0}}function ar(e){if(w(e).closed!==!0)throw new Error("Expected closed response");return{closed:!0}}function Ln(e){if(w(e).aborted!==!0)throw new Error("Expected aborted response");return{aborted:!0}}function On(e){if(w(e).stopped!==!0)throw new Error("Expected stopped response");return{stopped:!0}}function ls(e){const t=w(e);if(t.archived!==!0)throw new Error("Expected archived response");const i=t.sessionIds===void 0?void 0:Ko(t.sessionIds,"sessionIds"),s=ne(t,"archivedCount"),r=ne(t,"skippedAlreadyArchivedCount");return{archived:!0,...i===void 0?{}:{sessionIds:i},...s===void 0?{}:{archivedCount:s},...r===void 0?{}:{skippedAlreadyArchivedCount:r}}}function Wn(e){if(w(e).restored!==!0)throw new Error("Expected restored response");return{restored:!0}}function jn(e){if(w(e).detached!==!0)throw new Error("Expected detached response");return{detached:!0}}function ne(e,t){const i=e[t];if(i!==void 0){if(typeof i!="number")throw new Error(`Expected optional number field: ${t}`);return i}}function cs(e,t){const i=e[t];if(i===null)return null;if(typeof i!="number")throw new Error(`Expected number|null field: ${t}`);return i}function y(e,t){return t===void 0?{}:{[e]:t}}function Nn(e,t,i){const s=new URLSearchParams;i?.path!==void 0&&s.set("path",i.path),i?.staged===!0&&s.set("staged","true");const r=s.toString();return`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/diff${r?`?${r}`:""}`}function Fn(e,t){const i=new URLSearchParams;t?.limit!==void 0&&i.set("limit",String(t.limit)),t?.before!==void 0&&i.set("before",String(t.before));const s=i.toString();return`/api/sessions/${e}/messages${s?`?${s}`:""}`}function Bn(e,t,i,s){const r=new URLSearchParams;return r.set("path",i),s?.modifiedAt!==void 0&&r.set("v",s.modifiedAt),`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file/preview?${r.toString()}`}const lr={piWebStatus:()=>b("/api/pi-web/status",Tn)},cr={workspaceActivity:()=>b("/api/activity",Pn)},zn={projects:()=>b("/api/projects",O(rs)),addProject:(e,t,i)=>b("/api/projects",rs,{method:"POST",body:JSON.stringify({path:e,name:t,create:i})}),closeProject:e=>b(`/api/projects/${encodeURIComponent(e)}`,ar,{method:"DELETE"}),projectDirectories:e=>b(`/api/project-directories?q=${encodeURIComponent(e)}`,O(or))},qn={workspaces:e=>b(`/api/projects/${e}/workspaces`,O(Jo)),workspaceTree:(e,t,i="")=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/tree?path=${encodeURIComponent(i)}`,mn),workspaceFile:(e,t,i)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/file?path=${encodeURIComponent(i)}`,vn)},Hn={sessions:e=>b(`/api/sessions?cwd=${encodeURIComponent(e)}`,O(Jt)),startSession:e=>b("/api/sessions",Jt,{method:"POST",body:JSON.stringify({cwd:e})}),messages:(e,t)=>b(Fn(e,t),Qo),status:e=>b(`/api/sessions/${e}/status`,We),models:e=>b(`/api/sessions/${e}/models`,en),setModel:(e,t,i)=>b(`/api/sessions/${e}/model`,We,{method:"POST",body:JSON.stringify({provider:t,modelId:i})}),cycleModel:(e,t)=>b(`/api/sessions/${e}/model/cycle`,We,{method:"POST",body:JSON.stringify({direction:t})}),thinkingLevels:e=>b(`/api/sessions/${e}/thinking-levels`,sn),setThinkingLevel:(e,t)=>b(`/api/sessions/${e}/thinking-level`,We,{method:"POST",body:JSON.stringify({level:t})}),cycleThinkingLevel:e=>b(`/api/sessions/${e}/thinking-level/cycle`,We,{method:"POST"}),commands:e=>b(`/api/sessions/${e}/commands`,O(fn)),prompt:(e,t,i)=>b(`/api/sessions/${e}/prompt`,it,{method:"POST",body:JSON.stringify(i===void 0?{text:t}:{text:t,streamingBehavior:i})}),shell:(e,t)=>b(`/api/sessions/${e}/shell`,it,{method:"POST",body:JSON.stringify({text:t})}),runCommand:(e,t)=>b(`/api/sessions/${e}/commands/run`,as,{method:"POST",body:JSON.stringify({text:t})}),respondToCommand:(e,t,i)=>b(`/api/sessions/${e}/commands/respond`,as,{method:"POST",body:JSON.stringify({requestId:t,value:i})}),abort:e=>b(`/api/sessions/${e}/abort`,Ln,{method:"POST"}),stop:e=>b(`/api/sessions/${e}/stop`,On,{method:"POST"}),archive:e=>b(`/api/sessions/${e}/archive`,ls,{method:"POST"}),archiveWithDescendants:e=>b(`/api/sessions/${e}/archive-tree`,ls,{method:"POST"}),restore:e=>b(`/api/sessions/${e}/restore`,Wn,{method:"POST"}),detachParent:e=>b(`/api/sessions/${e}/detach-parent`,jn,{method:"POST"}),authProviders:e=>{const t=new URLSearchParams;e?.mode!==void 0&&t.set("mode",e.mode),e?.authType!==void 0&&t.set("authType",e.authType);const i=t.toString();return b(`/api/auth/providers${i===""?"":`?${i}`}`,ln)},saveApiKey:(e,t)=>b("/api/auth/api-key",it,{method:"POST",body:JSON.stringify({providerId:e,key:t})}),logoutProvider:e=>b("/api/auth/logout",it,{method:"POST",body:JSON.stringify({providerId:e})}),startOAuthLogin:e=>b("/api/auth/oauth",tt,{method:"POST",body:JSON.stringify({providerId:e})}),oauthFlow:e=>b(`/api/auth/oauth/${encodeURIComponent(e)}`,tt),respondOAuthFlow:(e,t,i)=>b(`/api/auth/oauth/${encodeURIComponent(e)}/respond`,tt,{method:"POST",body:JSON.stringify({requestId:t,value:i})}),cancelOAuthFlow:e=>b(`/api/auth/oauth/${encodeURIComponent(e)}/cancel`,tt,{method:"POST"})},fi={terminals:(e,t)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,O(Nt)),startTerminal:(e,t,i)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals`,Nt,{method:"POST",body:JSON.stringify(i??{})}),closeTerminal:(e,t,i)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}`,ar,{method:"DELETE"}),continueTerminal:(e,t,i)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}/continue`,Nt,{method:"POST"}),runTerminalCommand:(e,t)=>b(`/api/projects/${encodeURIComponent(t.workspace.projectId)}/workspaces/${encodeURIComponent(t.workspace.id)}/terminal-command-runs`,ct,{method:"POST",body:JSON.stringify({origin:e,title:t.title,command:t.command,metadata:t.metadata??{}})}),listCommandRuns:e=>b(`/api/terminal-command-runs${Vn(e)}`,O(ct)),getCommandRun:e=>Un(e),cancelCommandRun:e=>b(`/api/terminal-command-runs/${encodeURIComponent(e)}/cancel`,ct,{method:"POST"})};async function Un(e){const t=await fetch(`/api/terminal-command-runs/${encodeURIComponent(e)}`);if(t.status!==404){if(!t.ok){const i=await t.json().catch(()=>({}));throw new Error(Gn(i)??t.statusText)}return ct(await t.json())}}function Vn(e){if(e===void 0)return"";const t=new URLSearchParams;e.projectId!==void 0&&t.set("projectId",e.projectId),e.workspaceId!==void 0&&t.set("workspaceId",e.workspaceId),e.terminalId!==void 0&&t.set("terminalId",e.terminalId),e.statuses!==void 0&&e.statuses.length>0&&t.set("statuses",e.statuses.join(",")),e.metadata!==void 0&&Object.keys(e.metadata).length>0&&t.set("metadata",JSON.stringify(e.metadata));const i=t.toString();return i===""?"":`?${i}`}function Gn(e){if(!Kn(e))return;const t=e.error;return typeof t=="string"?t:void 0}function Kn(e){return typeof e=="object"&&e!==null}const Qn={files:(e,t,i,s)=>b(`/api/files?cwd=${encodeURIComponent(e)}&q=${encodeURIComponent(t)}${i!==void 0?`&kind=${encodeURIComponent(i)}`:""}${s!==void 0?`&mode=${encodeURIComponent(s)}`:""}`,O(or))},Jn={gitStatus:(e,t)=>b(`/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/git/status`,wn),gitDiff:(e,t,i)=>b(Nn(e,t,i),xn)},j={...lr,...cr,...zn,...qn,...Hn,...fi,...Qn,...Jn};function Zn(e){return new WebSocket(`${mi()}/api/sessions/${e}/events`)}function Cu(e,t,i,s){const r=s===void 0?"":`?cols=${encodeURIComponent(String(s.cols))}&rows=${encodeURIComponent(String(s.rows))}`;return new WebSocket(`${mi()}/api/projects/${encodeURIComponent(e)}/workspaces/${encodeURIComponent(t)}/terminals/${encodeURIComponent(i)}/socket${r}`)}function Xn(){return new WebSocket(`${mi()}/api/events`)}function mi(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}`}function Ft(){return{sessions:[],fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,selectedTerminalId:void 0,error:""}}function Yn(){return{projects:[],workspaces:[],sessions:[],messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,isLoadingProjects:!1,isLoadingWorkspaces:!1,selectedProject:void 0,selectedWorkspace:void 0,selectedSession:void 0,status:void 0,activity:void 0,sessionStatuses:{},sessionActivities:{},workspaceActivities:{},workspacesByProjectId:{},workspaceDeletionRuns:{},commandDialog:void 0,modelDialog:void 0,thinkingDialog:void 0,themeDialog:void 0,authDialog:void 0,actionPaletteOpen:!1,projectDialogOpen:!1,workspaceTool:"core:workspace.files",mainView:"chat",fileTree:[],expandedDirs:{},selectedFilePath:void 0,selectedFileContent:void 0,fileTreeStale:!1,gitStatus:void 0,selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0,gitStale:!1,activeTerminalCount:0,selectedTerminalId:void 0,piWebStatus:void 0,error:""}}function At(e,t){return t?.phase==="active"||e?.isStreaming===!0||e?.isBashRunning===!0||e?.isCompacting===!0||(e?.pendingMessageCount??0)>0}function dr(e){return e!==void 0&&(e.hasSessionActivity||e.hasTerminalActivity)}class ea{constructor(t,i,s={}){this.getState=t,this.setState=i,this.api=s.api??cr}async refresh(){const t=await this.api.workspaceActivity();this.setState({workspaceActivities:ta(t)})}applyWorkspaceActivity(t){this.setState({workspaceActivities:ia(this.getState().workspaceActivities,t)})}}function ta(e){const t={};for(const i of e.workspaces)dr(i)&&(t[i.cwd]=i);return t}function ia(e,t){const i={...e};return dr(t)?(i[t.cwd]=t,i):Object.fromEntries(Object.entries(i).filter(([s])=>s!==t.cwd))}class sa{constructor(t,i,s,r={}){this.getState=t,this.setState=i,this.applyStatus=s,this.api=r.api??j,this.pollIntervalMs=r.pollIntervalMs??1e3}dispose(){this.stopPolling()}handleSlashCommand(t){const i=ra(t);return i===void 0?!1:(i.command==="login"?this.openLogin(i.providerId):this.openLogout(i.providerId),!0)}async openLogin(t){if(t!==void 0&&t!==""){await this.openLoginProvider(t);return}this.setState({authDialog:{step:"method"}})}async chooseLoginMethod(t){try{const{providers:i}=await this.api.authProviders({mode:"login",authType:t});this.setState({authDialog:{step:"providers",mode:"login",authType:t,providers:i}})}catch(i){this.setState({error:String(i)})}}async selectLoginProvider(t,i){const s=this.getState().authDialog;if(s?.step!=="providers")return;const r=s.providers.find(o=>o.id===t&&(i===void 0||o.authType===i));r!==void 0&&(r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}}))}updateApiKey(t){const i=this.getState().authDialog;if(i?.step!=="apiKey")return;const s={...i};delete s.error,this.setState({authDialog:{...s,value:t}})}async saveApiKey(){const t=this.getState().authDialog;if(t?.step!=="apiKey")return;const i=t.value.trim();if(i===""){this.setState({authDialog:{...t,error:"API key is required"}});return}const s={...t};delete s.error,this.setState({authDialog:{...s,saving:!0}});try{await this.api.saveApiKey(t.provider.id,i),this.closeDialog(),this.refreshStatus()}catch(r){this.setState({authDialog:{...t,saving:!1,error:String(r)}})}}async openLogout(t){try{const{providers:i}=await this.api.authProviders({mode:"logout"});if(t!==void 0&&t!==""){const s=i.find(r=>r.id===t);s!==void 0?await this.logoutProvider(s.id):this.setState({error:`No stored credentials for ${t}`});return}this.setState({authDialog:{step:"logout",providers:i}})}catch(i){this.setState({error:String(i)})}}async logoutProvider(t){try{await this.api.logoutProvider(t),this.closeDialog(),this.refreshStatus()}catch(i){this.setState({error:String(i)})}}updateOAuthInput(t){const i=this.getState().authDialog;if(i?.step!=="oauth")return;const s={...i};delete s.error,this.setState({authDialog:{...s,inputValue:t}})}async respondOAuth(t){const i=this.getState().authDialog;if(i?.step!=="oauth")return;const s=i.flow.prompt??i.flow.select;if(s===void 0)return;const r=t??i.inputValue??"",o={...i};delete o.error,this.setState({authDialog:{...o,responding:!0}});try{const n=await this.api.respondOAuthFlow(i.flow.flowId,s.requestId,r);this.updateOAuthFlow(n)}catch(n){this.setState({authDialog:{...i,responding:!1,error:String(n)}})}}async cancelOAuth(){const t=this.getState().authDialog;if(t?.step!=="oauth"){this.closeDialog();return}this.stopPolling();try{await this.api.cancelOAuthFlow(t.flow.flowId)}catch{}this.closeDialog()}closeDialog(){this.stopPolling(),this.setState({authDialog:void 0})}async openLoginProvider(t){try{const{providers:i}=await this.api.authProviders({mode:"login"}),s=i.filter(o=>o.id===t);if(s.length===0){this.setState({error:`Auth provider not found: ${t}`});return}if(s.length>1){this.setState({authDialog:{step:"providers",mode:"login",providers:s}});return}const r=s[0];if(r===void 0)return;r.authType==="oauth"?await this.startOAuth(r):this.setState({authDialog:{step:"apiKey",provider:r,value:""}})}catch(i){this.setState({error:String(i)})}}async startOAuth(t){try{const i=await this.api.startOAuthLogin(t.id);this.updateOAuthFlow(i),this.startPolling(i.flowId)}catch(i){this.setState({error:String(i)})}}updateOAuthFlow(t){if(t.status==="complete"){this.stopPolling(),this.closeDialog(),this.refreshStatus();return}(t.status==="error"||t.status==="cancelled")&&this.stopPolling();const i=this.getState().authDialog,s=i?.step==="oauth"&&i.flow.flowId===t.flowId?i.inputValue??"":"",r=i?.step==="oauth"?i.flow.prompt?.requestId??i.flow.select?.requestId:void 0,o=t.prompt?.requestId??t.select?.requestId,n=r!==void 0&&r===o,a=n?s:"",l=n&&i?.step==="oauth"?i.responding===!0:!1;this.setState({authDialog:{step:"oauth",flow:t,inputValue:a,responding:l}})}startPolling(t){this.stopPolling(),this.pollTimer=window.setInterval(()=>{this.poll(t)},this.pollIntervalMs)}stopPolling(){this.pollTimer!==void 0&&(window.clearInterval(this.pollTimer),this.pollTimer=void 0)}async poll(t){const i=this.getState().authDialog;if(i?.step!=="oauth"||i.flow.flowId!==t){this.stopPolling();return}try{this.updateOAuthFlow(await this.api.oauthFlow(t))}catch(s){this.stopPolling(),this.setState({authDialog:{...i,error:String(s)}})}}async refreshStatus(){const t=this.sessionId();if(t!==void 0)try{this.applyStatus(await this.api.status(t))}catch{}}sessionId(){const t=this.getState().selectedSession;if(!(t===void 0||t.archived===!0))return t.id}}function ra(e){const t=e.trim(),i=/^\/(login|logout)(?:\s+(\S+))?\s*$/u.exec(t);if(i===null)return;const s=i[1];if(s!=="login"&&s!=="logout")return;const r=i[2];return r===void 0||r===""?{command:s}:{command:s,providerId:r}}function Ke(e){return e.replaceAll(":",".")}function oa(e){const t=new URLSearchParams(window.location.search),i=`${e}--`,s={};for(const[r,o]of t.entries()){if(!r.startsWith(i))continue;const n=r.slice(i.length),a=s[n];a===void 0?s[n]=o:Array.isArray(a)?a.push(o):s[n]=[a,o]}return s}function Bt(e,t){const i=oa(e)[t];return Array.isArray(i)?i[0]:i===""?void 0:i}function Qe(e,t,i,s){const r=new URL(window.location.href),o=`${e}--${t}`;if(r.searchParams.delete(o),i!=null&&i!=="")if(Array.isArray(i))for(const n of i)r.searchParams.append(o,String(n));else r.searchParams.set(o,String(i));na(r,s)}function na(e,t){const i=`${e.pathname}${e.search}${e.hash}`,s=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==s&&(t?.replace===!0?window.history.replaceState({},"",e):window.history.pushState({},"",e))}const ds=Ke("core:workspace.files");class aa{constructor(t,i,s){this.getState=t,this.setState=i,this.updateUrl=s}async refreshFiles(){const t=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(t===void 0||i===void 0))try{const s=await j.workspaceTree(t.id,i.id),r={...this.getState().expandedDirs};await Promise.all(Object.keys(r).map(async o=>{r[o]=(await j.workspaceTree(t.id,i.id,o)).entries})),this.setState({fileTree:s.entries,expandedDirs:r,fileTreeStale:!1,error:""})}catch(s){this.setState({error:String(s)})}}async expandDir(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0)){if(this.getState().expandedDirs[t]!==void 0){this.setState({expandedDirs:ca(this.getState().expandedDirs,t)});return}try{const r=await j.workspaceTree(i.id,s.id,t);this.setState({expandedDirs:{...this.getState().expandedDirs,[t]:r.entries},error:""})}catch(r){this.setState({error:String(r)})}}}async selectFile(t){this.setState({selectedFilePath:t,selectedFileContent:void 0,workspaceTool:"core:workspace.files",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.files"}),Qe(ds,"file",t),this.updateUrl({replace:!0}),await this.restoreFile(t)}async restoreFile(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0)){this.setState({selectedFilePath:t,selectedFileContent:void 0});try{const r=await j.workspaceFile(i.id,s.id,t);this.getState().selectedFilePath===t&&this.setState({selectedFileContent:r,error:""})}catch(r){if(this.getState().selectedFilePath!==t)return;if(la(r)){this.setState({selectedFilePath:void 0,selectedFileContent:void 0,error:""}),Qe(ds,"file",void 0,{replace:!0}),this.updateUrl({replace:!0});return}this.setState({error:String(r)})}}}}function la(e){const t=String(e);return t.includes("Path does not exist")||t.includes("ENOENT")||t.includes("no such file or directory")}function ca(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}const ps=Ke("core:workspace.git");class da{constructor(t,i,s){this.getState=t,this.setState=i,this.updateUrl=s}dispose(){this.pollTimer!==void 0&&window.clearInterval(this.pollTimer),this.pollTimer=void 0}async refreshGit(){const t=this.getState().selectedProject,i=this.getState().selectedWorkspace;if(!(t===void 0||i===void 0))try{const s=await j.gitStatus(t.id,i.id);this.setState({gitStatus:s,gitStale:!1,error:""});const r=this.getState().selectedDiffPath;r!==void 0&&(s.files.some(o=>o.path===r)?await this.refreshDiff(r):(this.setState({selectedDiffPath:void 0,selectedDiff:void 0,selectedStagedDiff:void 0}),Qe(ps,"diff",void 0,{replace:!0})))}catch(s){this.setState({error:String(s)})}}async selectDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0,workspaceTool:"core:workspace.git",mainView:this.getState().mainView==="chat"?"chat":"core:workspace.git"}),Qe(ps,"diff",t),this.updateUrl({replace:!0}),await this.refreshDiff(t)}async restoreDiff(t){this.setState({selectedDiffPath:t,selectedDiff:void 0,selectedStagedDiff:void 0}),await this.refreshDiff(t)}async refreshDiff(t){const i=this.getState().selectedProject,s=this.getState().selectedWorkspace;if(!(i===void 0||s===void 0))try{const[r,o]=await Promise.all([j.gitDiff(i.id,s.id,{path:t}),j.gitDiff(i.id,s.id,{path:t,staged:!0})]);this.setState({selectedDiff:r,selectedStagedDiff:o,error:""})}catch(r){this.setState({error:String(r)})}}updatePolling(){this.dispose();const t=this.getState();(t.workspaceTool==="core:workspace.git"||t.mainView==="core:workspace.git")&&(this.pollTimer=window.setInterval(()=>{this.refreshGit()},8e3))}}class pa{constructor(t,i,s){this.getState=t,this.setState=i,this.workspaces=s}async loadProjects(){this.setState({error:"",isLoadingProjects:!0});try{const t=await j.projects(),i=new Set(t.map(r=>r.id)),s=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([r])=>i.has(r)));this.setState({projects:t,workspacesByProjectId:s})}catch(t){this.setState({error:String(t)})}finally{this.setState({isLoadingProjects:!1})}}async addProject(t,i){if(t.trim()!=="")try{const s=await j.addProject(t.trim(),void 0,i),r=this.getState().projects;this.setState({projects:[...r.filter(o=>o.id!==s.id),s],projectDialogOpen:!1}),await this.workspaces.selectProject(s)}catch(s){this.setState({error:String(s)})}}async closeProject(t){try{await j.closeProject(t),this.workspaces.forgetProject(t);const i=this.getState();this.setState({projects:i.projects.filter(s=>s.id!==t)}),i.selectedProject?.id===t&&this.workspaces.clearSelection()}catch(i){this.setState({error:String(i)})}}}const Zt="pi-web:cached-new-sessions:v1",ha="browserCachedNew";function Ze(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function hs(e,t=Ze()){if(e.messageCount!==0||e.archived===!0)return;const i=gi(t).filter(s=>s.id!==e.id);vi([Xt(e),...i],t)}function Xt(e){return{...e,browserCachedNew:!0}}function us(e,t=Ze()){const i=gi(t).filter(s=>s.id!==e);vi(i,t)}function ua(e,t,i=Ze()){const s=new Set(t.map(a=>a.id)),r=gi(i),o=r.filter(a=>!s.has(a.id));return o.length!==r.length&&vi(o,i),[...o.filter(a=>a.cwd===e),...t]}function me(e){return e===void 0?!1:ga(e)&&e.browserCachedNew===!0}function fa(e){return{id:e.id,path:e.path,cwd:e.cwd,...e.name===void 0?{}:{name:e.name},created:e.created,modified:e.modified,messageCount:e.messageCount,firstMessage:e.firstMessage,...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath},...e.archived===!0?{archived:!0}:{},...e.archivedAt===void 0?{}:{archivedAt:e.archivedAt}}}function gi(e=Ze()){try{const t=e?.getItem(Zt);if(t==null||t==="")return[];const i=JSON.parse(t);return Array.isArray(i)?i.flatMap(s=>ma(s)):[]}catch{return[]}}function vi(e,t=Ze()){try{e.length===0?t?.removeItem(Zt):t?.setItem(Zt,JSON.stringify(e))}catch{}}function ma(e){if(!va(e))return[];const t=Te(e,"id"),i=Te(e,"path"),s=Te(e,"cwd"),r=Te(e,"created"),o=Te(e,"modified"),n=Te(e,"firstMessage"),a=ba(e,"messageCount");if(t===void 0||i===void 0||s===void 0||r===void 0||o===void 0||n===void 0||a!==0)return[];const l=fs(e,"name"),d=fs(e,"parentSessionPath");return[{id:t,path:i,cwd:s,...l===void 0?{}:{name:l},created:r,modified:o,messageCount:a,firstMessage:n,...d===void 0?{}:{parentSessionPath:d},browserCachedNew:!0}]}function ga(e){return ha in e}function va(e){return typeof e=="object"&&e!==null}function Te(e,t){const i=e[t];return typeof i=="string"?i:void 0}function fs(e,t){const i=e[t];return i===void 0||typeof i!="string"?void 0:i}function ba(e,t){const i=e[t];return typeof i=="number"?i:void 0}function wa(e){return _a(e.flatMap(bi)).filter(t=>t.parts.length>0)}function oe(e,t){return{role:e,parts:[{type:"text",text:t}]}}function st(e,t){const i=Ta(t);return i===void 0?e:{...e,meta:i}}function ya(e,t,i){if(i==="")return e;const s=e.at(-1),r=s?.parts.at(-1);return s?.role===t&&r?.type==="text"?[...e.slice(0,-1),{...s,parts:[...s.parts.slice(0,-1),{...r,text:r.text+i}]}]:s?.role===t?[...e.slice(0,-1),{...s,parts:[...s.parts,{type:"text",text:i}]}]:[...e,oe(t,i)]}function xa(e,t){if(t==="")return e;const i=e.at(-1),s=i?.parts.at(-1);return i?.role==="assistant"&&s?.type==="thinking"?[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:s.text+t}]}]:i?.role==="assistant"?[...e.slice(0,-1),{...i,parts:[...i.parts,{type:"thinking",text:t}]}]:[...e,{role:"assistant",parts:[{type:"thinking",text:t}]}]}function bi(e){if(ka(e))return[e];if(P(e,"role")==="bashExecution")return[st(Aa(e),e)];const t=Ra(P(e,"role")),i=Ma(Q(e,"content"),e),s=t==="user"?Sa(i):void 0;if(s!==void 0)return s.map(a=>st(a,e));const r=Pa(e);if(t==="tool")return[st({role:t,parts:i,...r===void 0?{}:{source:r}},e)];const o=i.filter(a=>a.type!=="empty"),n=t==="assistant"&&o.length>0&&o.every(a=>a.type==="skillRead")?"skill":t;return o.length>0?[st({role:n,parts:o,...r===void 0?{}:{source:r}},e)]:[]}function ka(e){const t=P(e,"role");return(t==="user"||t==="assistant"||t==="tool"||t==="system"||t==="bash"||t==="skill")&&Array.isArray(Q(e,"parts"))}function Sa(e){if(e.length!==1||e[0]?.type!=="text")return;const t=$a(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 $a(e){const t=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/.exec(e);if(t===null)return;const i=t[4]?.trim();return{name:t[1]??"skill",location:t[2]??"",content:t[3]??"",...i===void 0||i===""?{}:{userMessage:i}}}function Pa(e){const t=P(e,"source");if(t==="compaction"||t==="branch_summary")return t}function Ta(e){const t=Ca(Q(e,"timestamp")),i=Ia(e);if(!(t===void 0&&i===void 0))return{...t===void 0?{}:{timestamp:t},...i===void 0?{}:{model:i}}}function Ca(e){if(typeof e=="number"&&Number.isFinite(e))return new Date(e).toISOString();if(typeof e!="string"||e==="")return;const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function Ia(e){if(P(e,"role")!=="assistant")return;const t=P(e,"provider"),i=P(e,"model"),s=P(e,"responseModel");if(!((t===void 0||t==="")&&(i===void 0||i==="")&&(s===void 0||s==="")))return{...t===void 0||t===""?{}:{provider:t},...i===void 0||i===""?{}:{id:i},...s===void 0||s===""?{}:{responseId:s}}}function Aa(e){const t=P(e,"command")??"",i=dt(e,"excludeFromContext")===!0?["excluded from context","",`$ ${t}`]:[`$ ${t}`],s=Q(e,"output");s!=null&&i.push("",gt(s));const r=Q(e,"exitCode");r!=null&&i.push("",`exit ${gt(r)}`),dt(e,"cancelled")===!0&&i.push("","cancelled"),dt(e,"truncated")===!0&&i.push("","output truncated");const o=P(e,"fullOutputPath");return o!==void 0&&o!==""&&i.push("",`full output: ${o}`),{role:"bash",parts:[{type:"text",text:i.join(`
|
|
5
|
+
`)}]}}function Ra(e){return e==="assistant"?"assistant":e==="user"?"user":e==="toolResult"?"tool":"system"}function Ma(e,t){return typeof e=="string"?e!==""?[{type:"text",text:e}]:[]:Array.isArray(e)?e.flatMap(i=>{const s=P(i,"type"),r=P(i,"text");if(s==="text")return r!==void 0&&r!==""?[{type:"text",text:r}]:[];if(s==="thinking"){const o=P(i,"thinking")??r;return o!==void 0&&o!==""?[{type:"thinking",text:o}]:[]}if(s==="toolCall"){const o=P(i,"name")??"tool",n=Q(i,"arguments"),a=o==="read"?Da(P(n,"path")):void 0;if(a!==void 0)return[{type:"skillRead",...a}];const l=P(i,"id");return[{type:"toolCall",...l===void 0?{}:{toolCallId:l},toolName:o,summary:Xe(n),...n===void 0?{}:{args:n}}]}return s==="image"?[{type:"text",text:"[image]"}]:ms(i)}).map(i=>i.type==="text"&&P(t,"role")==="toolResult"?Ea(i.text,t):i):ms(e)}function Ea(e,t){const i=P(t,"toolCallId"),s=Q(t,"content"),r=Q(t,"details");return{type:"toolResult",...i===void 0?{}:{toolCallId:i},toolName:P(t,"toolName")??"tool",text:e,...s===void 0?{}:{content:s},...r===void 0?{}:{details:r},isError:dt(t,"isError")===!0}}function Da(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const i=t.split("/").at(-2);if(!(i===void 0||i===""))return{name:i,path:e}}function _a(e){const t=[],i=new Map;for(const s of e){let r=[];const o={...s.source===void 0?{}:{source:s.source},...s.meta===void 0?{}:{meta:s.meta}},n=()=>{r.length!==0&&(t.push({role:s.role,parts:r,...o}),r=[])};for(const a of s.parts){if(a.type==="toolCall"){n();const l=La(a),d=t.length;t.push({role:"tool",parts:[l],...o}),l.toolCallId!==void 0&&i.set(l.toolCallId,{lineIndex:d,partIndex:0});continue}if(a.type==="toolResult"){const l=a.toolCallId===void 0?void 0:i.get(a.toolCallId);if(l!==void 0&&Oa(t,l,a)){i.delete(a.toolCallId??"");continue}}r.push(a)}n()}return t}function La(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 Oa(e,t,i){const s=e[t.lineIndex],r=s?.parts[t.partIndex];if(s===void 0||r?.type!=="toolExecution")return!1;const o=mt(i.details)??r.preview,n={...r,status:i.isError?"error":"success",resultText:i.text,...i.content===void 0?{}:{content:i.content},...i.details===void 0?{}:{details:i.details},...o===void 0?{}:{preview:o}};return e[t.lineIndex]={...s,parts:[...s.parts.slice(0,t.partIndex),n,...s.parts.slice(t.partIndex+1)]},!0}function mt(e){const t=Q(e,"preview");if(!wi(t))return;const i=P(t,"diff"),s=P(t,"error"),r=ja(t,"firstChangedLine");if(!(i===void 0&&s===void 0&&r===void 0))return{...i===void 0?{}:{diff:i},...s===void 0?{}:{error:s},...r===void 0?{}:{firstChangedLine:r}}}function ms(e){return e==null?[]:typeof e=="object"?[{type:"text",text:Xe(e)}]:[{type:"text",text:gt(e)}]}function Xe(e){if(!wi(e))return gt(e);const t=P(e,"command");if(t!==void 0)return t;const i=P(e,"path");if(i!==void 0)return i;if(typeof e.oldText=="string"&&typeof e.newText=="string")return"edit text replacement";const s=e.edits;return Array.isArray(s)?`${String(s.length)} edit${s.length===1?"":"s"}`:Object.entries(e).filter(([,o])=>o!=null).slice(0,3).map(([o,n])=>`${o}: ${Wa(n)}`).join(" · ")}function Wa(e){return typeof e=="string"?e.length>80?`${e.slice(0,77)}…`:e:typeof e=="number"||typeof e=="boolean"?String(e):Array.isArray(e)?`${String(e.length)} item${e.length===1?"":"s"}`:typeof e=="object"&&e!==null?"object":""}function wi(e){return typeof e=="object"&&e!==null}function Q(e,t){return wi(e)?e[t]:void 0}function P(e,t){const i=Q(e,t);return typeof i=="string"?i:void 0}function dt(e,t){const i=Q(e,t);return typeof i=="boolean"?i:void 0}function ja(e,t){const i=Q(e,t);return typeof i=="number"&&Number.isFinite(i)?i:void 0}function gt(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):""}const Na="pi-web:prompt-draft:";function vt(e){return`${Na}${e}`}function Rt(){try{return typeof localStorage>"u"?void 0:localStorage}catch{return}}function pr(e,t=Rt()){try{return t?.getItem(vt(e))??""}catch{return""}}function bt(e,t,i=Rt()){try{t?i?.setItem(vt(e),t):i?.removeItem(vt(e))}catch{}}function yi(e,t=Rt()){try{t?.removeItem(vt(e))}catch{}}function Fa(e,t,i=Rt()){const s=pr(e,i);s!==""&&(bt(t,s,i),yi(e,i))}function Ba(e,t){return oe("bash",`${t===!0?`excluded from context
|
|
6
|
+
|
|
7
|
+
`:""}$ ${e}`)}function za(e,t){const i=e.at(-1),s=i?.parts.at(-1);if(i?.role!=="bash"||s?.type!=="text")return[...e,oe("bash",t)];const r=Ha(s.text)?"":`
|
|
8
|
+
|
|
9
|
+
`;return[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:s.text+r+t}]}]}function qa(e,t){const i=e.at(-1),s=i?.parts.at(-1);if(i?.role!=="bash"||s?.type!=="text")return e;const r=[];return!s.text.includes(`
|
|
10
|
+
|
|
11
|
+
`)&&(t.output===void 0||t.output==="")&&r.push("(no output)"),t.isError===!0&&r.push(t.output??"Bash command failed"),t.exitCode!=null&&r.push(`exit ${String(t.exitCode)}`),t.cancelled===!0&&r.push("cancelled"),t.truncated===!0&&r.push("output truncated"),t.fullOutputPath!==void 0&&t.fullOutputPath!==""&&r.push(`full output: ${t.fullOutputPath}`),r.length===0?e:[...e.slice(0,-1),{...i,parts:[...i.parts.slice(0,-1),{...s,text:`${s.text}
|
|
12
|
+
|
|
13
|
+
${r.join(`
|
|
14
|
+
`)}`}]}]}function Ha(e){const t=e.lastIndexOf(`
|
|
15
|
+
|
|
16
|
+
`),i=e.lastIndexOf("$ ");return t>i}function Ua(e,t){if(t.type==="message.append")return tl(e,t.message);if(t.type==="assistant.delta")return ya(e,"assistant",t.text);if(t.type==="assistant.thinking.delta")return xa(e,t.text);if(t.type==="tool.start")return Qa(e,t);if(t.type==="tool.update")return ur(e,t.toolCallId,i=>Ja(i,t));if(t.type==="tool.end")return hr(e,t.toolCallId,t.toolName,Xe(t.content),t.text,t.isError,t.content,t.details);if(t.type==="shell.start")return[...e,Ba(t.command,t.excludeFromContext)];if(t.type==="shell.chunk")return za(e,t.chunk);if(t.type==="shell.end")return qa(e,t);if(t.type==="command.output")return[...e,oe(t.level==="error"?"system":"tool",t.message)];if(t.type==="session.error")return[...e,oe("system",t.message)];if(t.type==="message.end")return t.message===void 0?void 0:Va(e,t.message)}function Va(e,t){const i=Za(t);if(i!==void 0)return hr(e,i.toolCallId,i.toolName,Xe(i.content),i.text,i.isError,i.content,i.details);const s=bi(t)[0];if(s===void 0)return;const r=s.role==="assistant"?Ga(s):s;if(r.parts.length===0)return e;const o=Xa(e,r);if(o>=0)return[...e.slice(0,o),r,...e.slice(o+1)];const n=e.at(-1);return n?.role!==r.role?[...e,r]:r.role==="assistant"||el(n,r)?[...e.slice(0,-1),r]:[...e,r]}function Ga(e){return{...e,parts:e.parts.filter(t=>t.type!=="toolCall")}}function Ka(e){if(e===void 0||e==="")return;const t=e.replace(/\\/g,"/");if(!t.endsWith("/SKILL.md")&&t!=="SKILL.md")return;const i=t.split("/").at(-2);if(!(i===void 0||i===""))return{name:i,path:e}}function Qa(e,t){const i=t.toolName==="read"?Ka(be(t.args,"path")):void 0;if(i!==void 0)return il(e,{role:"skill",parts:[{type:"skillRead",...i}]});const s={type:"toolExecution",...t.toolCallId===""?{}:{toolCallId:t.toolCallId},toolName:t.toolName,summary:t.summary||Xe(t.args),...t.args===void 0?{}:{args:t.args},status:"running"};return[...e,{role:"tool",parts:[s]}]}function Ja(e,t){const i=mt(t.details)??e.preview;return{...e,status:e.status==="pending"?"running":e.status,...t.text===""?{}:{resultText:t.text},...t.content===void 0?{}:{content:t.content},...t.details===void 0?{}:{details:t.details},...i===void 0?{}:{preview:i}}}function hr(e,t,i,s,r,o,n,a){const l=ur(e,t,p=>{const f=mt(a)??p.preview;return{...p,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...f===void 0?{}:{preview:f}}});if(l!==e)return l;const d=mt(a),u={type:"toolExecution",...t===void 0||t===""?{}:{toolCallId:t},toolName:i,summary:s,status:o?"error":"success",resultText:r,...n===void 0?{}:{content:n},...a===void 0?{}:{details:a},...d===void 0?{}:{preview:d}};return[...e,{role:"tool",parts:[u]}]}function ur(e,t,i){if(t===void 0||t==="")return e;for(let s=e.length-1;s>=0;s--){const r=e[s];if(r===void 0)continue;const o=r.parts.findIndex(l=>l.type==="toolExecution"&&l.toolCallId===t);if(o<0)continue;const n=r.parts[o];if(n?.type!=="toolExecution")continue;const a={...r,parts:[...r.parts.slice(0,o),i(n),...r.parts.slice(o+1)]};return[...e.slice(0,s),a,...e.slice(s+1)]}return e}function Za(e){if(be(e,"role")!=="toolResult")return;const t=be(e,"toolCallId"),i=yt(e,"content");return{...t===void 0?{}:{toolCallId:t},toolName:be(e,"toolName")??"tool",text:fr(i),isError:rl(e,"isError")===!0,content:i,details:yt(e,"details")}}function fr(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(fr).filter(t=>t!=="").join(`
|
|
17
|
+
`);if(typeof e=="object"&&e!==null){const t=be(e,"text")??be(e,"content")??be(e,"output");if(t!==void 0)return t}return""}function Xa(e,t){const i=wt(t);if(i.length===0)return-1;for(let s=e.length-1;s>=0;s--){const r=e[s];if(r?.role!=="skill")continue;const o=wt(r);if(mr(o,i))return s}return-1}function wt(e){return e===void 0?[]:e.parts.filter(t=>t.type==="skillRead")}function mr(e,t){return e.length===t.length&&e.every((i,s)=>Ya(i,t[s]))}function Ya(e,t){return t===void 0?!1:gs(e.path)===gs(t.path)||e.name===t.name}function gs(e){return e.replace(/\\/g,"/")}function el(e,t){return vs(e)===vs(t)}function vs(e){return e.parts.filter(t=>t.type==="text").map(t=>t.text).join(`
|
|
18
|
+
|
|
19
|
+
`)}function tl(e,t){const i=bi(t);return i.length===0?e:[...e,...i]}function il(e,t){const i=e.at(-1);return t.role==="skill"&&mr(wt(i),wt(t))?e:i?.role===t.role&&t.role!=="skill"?[...e.slice(0,-1),{...i,parts:[...i.parts,...t.parts]}]:[...e,t]}function sl(e){return typeof e=="object"&&e!==null}function yt(e,t){return sl(e)?e[t]:void 0}function be(e,t){const i=yt(e,t);return typeof i=="string"?i:void 0}function rl(e,t){const i=yt(e,t);return typeof i=="boolean"?i:void 0}const ol="pi-web:chat-history:v2:",nl=1800*1e3;function al(e){try{const t=sessionStorage.getItem(Yt(e));if(t===null||t==="")return;const i=JSON.parse(t);if(!hl(i))return;if(Date.now()-i.savedAt>nl){sessionStorage.removeItem(Yt(e));return}return{messages:i.messages,start:i.start,total:i.total}}catch{return}}function ll(e,t){try{sessionStorage.setItem(Yt(e),JSON.stringify({...t,savedAt:Date.now()}))}catch{}}function cl(e,t){if(e===void 0||!ei(e))return t;if(!ei(t))return e;if(dl(e,t))return t;const i=Math.min(e.start,t.start),s=Math.max(e.start+e.messages.length,t.start+t.messages.length),r=new Array(s-i);return bs(r,i,e),bs(r,i,t),pl(r)?t:{start:i,total:Math.max(e.total,t.total),messages:r}}function dl(e,t){return e.total>t.total&&e.start===0&&t.start===0&&t.messages.length===t.total}function pl(e){for(let t=0;t<e.length;t+=1)if(!(t in e)||e[t]===void 0)return!0;return!1}function bs(e,t,i){i.messages.forEach((s,r)=>{e[i.start-t+r]=s})}function Yt(e){return`${ol}${e}`}function hl(e){if(typeof e!="object"||e===null||!("messages"in e)||!("start"in e)||!("total"in e)||!("savedAt"in e))return!1;const{messages:t,start:i,total:s,savedAt:r}=e;return Array.isArray(t)&&typeof i=="number"&&typeof s=="number"&&typeof r=="number"&&ei({messages:t,start:i,total:s})}function ei(e){return Number.isInteger(e.start)&&Number.isInteger(e.total)&&e.start>=0&&e.total>=e.start&&e.messages.length<=e.total-e.start&&!e.messages.some(ul)}function ul(e){return typeof e=="object"&&e!==null&&"role"in e&&"parts"in e&&!("content"in e)&&typeof e.role=="string"&&Array.isArray(e.parts)}const fl={read:al,write:ll};class ml{constructor(t=fl){this.cache=t,this.rawHistoryPages=new Map}cachedView(t){return ws(this.rawHistoryPage(t))}mergeHistory(t,i){const s=cl(this.rawHistoryPage(t),i);return this.rawHistoryPages.set(t,s),this.cache.write(t,s),ws(s)}applyLiveEvent(t,i){return Ua(t,i)}rawHistoryPage(t){const i=this.rawHistoryPages.get(t)??this.cache.read(t);return i!==void 0&&this.rawHistoryPages.set(t,i),i}}function ws(e){const t=e?.start??0;return{messages:wa(e?.messages??[]),messagePageStart:t,messagePageEnd:t+(e?.messages.length??0),messagePageTotal:e?.total??0}}function xi(e){const t=e.trimStart();return t.startsWith("!")?{kind:"shell",excludeFromContext:t.startsWith("!!")}:gr(e).startsWith("/")?{kind:"command"}:vl(e)?{kind:"file"}:{kind:"normal"}}function gl(e){return xi(e).kind==="shell"}function gr(e){const t=Math.max(e.lastIndexOf(" "),e.lastIndexOf(`
|
|
20
|
+
`))+1;return e.slice(t)}function vl(e){const t=gr(e);if(t.startsWith("@"))return!0;const i=e.length-t.length;if(e.slice(0,i).endsWith("@ "))return!0;const s=e.lastIndexOf('"');if(s===-1)return!1;const r=e.slice(0,s);return r.endsWith("@")||r.endsWith("@ ")}class bl{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1,this.hasOpened=!1}connect(t,i,s){this.close(),this.sessionId=t,this.onEvent=i,this.onReconnect=s,this.shouldReconnect=!0,this.open()}setHandler(t){this.onEvent=t}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),br(this.socket),this.socket=void 0,this.sessionId=void 0,this.onEvent=void 0,this.onReconnect=void 0,this.hasOpened=!1}open(){if(this.sessionId===void 0||this.sessionId===""||!this.shouldReconnect)return;const t=Zn(this.sessionId);this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.hasOpened&&this.onReconnect?.(),this.hasOpened=!0},t.onmessage=i=>{this.handleMessage(i.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const i=await vr(t);yl(i)&&this.onEvent?.(i)}}class wl{constructor(){this.reconnectDelay=500,this.shouldReconnect=!1}connect(t,i){this.close(),this.onEvent=t,this.onOpen=i,this.shouldReconnect=!0,this.open()}close(){this.shouldReconnect=!1,window.clearTimeout(this.reconnectTimer),br(this.socket),this.socket=void 0,this.onEvent=void 0,this.onOpen=void 0}open(){if(!this.shouldReconnect)return;const t=Xn();this.socket=t,t.onopen=()=>{this.reconnectDelay=500,this.onOpen?.()},t.onmessage=i=>{this.handleMessage(i.data)},t.onerror=()=>{t.close()},t.onclose=()=>{this.socket===t&&(this.socket=void 0),this.scheduleReconnect()}}scheduleReconnect(){if(!this.shouldReconnect)return;window.clearTimeout(this.reconnectTimer);const t=this.reconnectDelay;this.reconnectDelay=Math.min(this.reconnectDelay*1.6,5e3),this.reconnectTimer=window.setTimeout(()=>{this.open()},t)}async handleMessage(t){const i=await vr(t);kl(i)&&this.onEvent?.(i)}}function yl(e){const t=ki(e);return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","agent.start","agent.end","message.end","status.update","activity.update","command.output","session.error","session.name","pi.event"].includes(t)}function xl(e){const t=ki(e);return t==="status.update"||t==="activity.update"||t==="session.name"}function kl(e){const t=ki(e);return xl(e)||t==="terminal.created"||t==="terminal.exited"||t==="terminal.closed"||t==="workspace.activity"}function ki(e){if(typeof e!="object"||e===null||!("type"in e))return"";const t=e.type;return typeof t=="string"?t:""}async function vr(e){try{return typeof e=="string"?JSON.parse(e):e instanceof Blob?JSON.parse(await e.text()):e instanceof ArrayBuffer?JSON.parse(new TextDecoder().decode(e)):void 0}catch{return}}function br(e){if(e!==void 0){if(e.onmessage=null,e.onerror=null,e.onclose=null,e.readyState===WebSocket.CONNECTING){e.onopen=()=>{e.close()};return}e.close()}}class Sl{constructor(){this.sessionIdsByCwd=new Map}latestSessionId(t){return this.sessionIdsByCwd.get(t)}rememberSession(t){this.sessionIdsByCwd.set(t.cwd,t.id)}forgetWorkspace(t){this.sessionIdsByCwd.delete(t)}}function $l(e,t){const i=t?.targetSessionId;if(i!==void 0&&i!=="")return Tl(e,i);const s=t?.latestSessionId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e.find(r=>r.archived!==!0):e.find(r=>r.archived!==!0)}function Pl(e,t){return t?.archived!==!0?!1:!e.some(i=>i.archived!==!0)}function Tl(e,t){return e.find(i=>i.id===t||i.id.startsWith(t))}function Cl(e,t,i){return wr(e,[t],i)}function wr(e,t,i){const s=new Set(t);return e.map(r=>s.has(r.id)?{...r,archived:!0,archivedAt:i}:r)}function Il(e,t,i){return yr(e,t,[i])}function yr(e,t,i){if(t===void 0||!i.includes(t))return{type:"unchanged"};const s=new Set(i),r=e.find(o=>!s.has(o.id)&&o.archived!==!0);return r===void 0?{type:"clear"}:{type:"select",session:r}}const je=100;class Al{constructor(t,i,s,r=new Sl,o={}){this.getState=t,this.setState=i,this.updateUrl=s,this.sessionSelection=r,this.selectionSeq=0,this.pendingTranscriptEvents=[],this.socket=o.socket??new bl,this.api=o.api??j,this.transcripts=o.transcripts??new ml}applyGlobalEvent(t){t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):this.applySessionName(t.sessionId,t.name)}dispose(){this.socket.close(),this.clearPendingTranscriptEvents()}clearActiveSession(){this.selectionSeq+=1,this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents(),this.setState({selectedSession:void 0,messages:[],messagePageStart:0,messagePageEnd:0,messagePageTotal:0,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0})}deselectSession(t){const i=this.getState(),s=i.selectedSession?.cwd??i.selectedWorkspace?.path;t?.forgetRememberedSelection===!0&&s!==void 0&&this.sessionSelection.forgetWorkspace(s),this.clearActiveSession(),t?.updateUrl!==!1&&this.updateUrl()}clearSelectionAfterArchivedCollapse(){const t=this.getState();Pl(t.sessions,t.selectedSession)&&this.deselectSession({forgetRememberedSelection:!0})}async startSession(){const t=this.getState().selectedWorkspace;if(t)try{const i=await this.api.startSession(t.path);hs(i);const s=Xt(i);this.setState({sessions:[s,...this.getState().sessions]}),await this.selectSession(s)}catch(i){this.setState({error:String(i)})}}preferredSession(t,i,s){return $l(i,{targetSessionId:s,latestSessionId:this.sessionSelection.latestSessionId(t)})}async selectSession(t,i){this.sessionSelection.rememberSession(t);const s=++this.selectionSeq;this.socket.close(),this.catchupStreamSessionId=void 0,this.clearPendingTranscriptEvents();const r=this.transcripts.cachedView(t.id);this.setState({selectedSession:t,...r,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:t.archived===!0?void 0:this.getState().sessionStatuses[t.id],activity:t.archived===!0?void 0:this.getState().sessionActivities[t.id]});try{if(t.archived===!0){const u=await this.api.messages(t.id,{limit:je});if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const p=this.transcripts.mergeHistory(t.id,u);this.setState({...p,isLoadingEarlierMessages:!1,isReceivingPartialStream:!1,status:void 0,activity:void 0}),i?.updateUrl!==!1&&this.updateUrl();return}const o=[];this.socket.connect(t.id,u=>o.push(u),()=>{this.refreshSelectedSession(t.id)});const[n,a]=await Promise.all([this.api.messages(t.id,{limit:je}),this.api.status(t.id)]);if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;const l=this.transcripts.mergeHistory(t.id,n),d=a.isStreaming;this.catchupStreamSessionId=d?t.id:void 0,this.setState({...l,isLoadingEarlierMessages:!1,isReceivingPartialStream:d,status:a,activity:this.getState().sessionActivities[t.id]}),this.applyStatus(a);for(const u of o)this.applyEvent(u);this.socket.setHandler(u=>{this.applyEvent(u)}),i?.updateUrl!==!1&&this.updateUrl()}catch(o){if(s!==this.selectionSeq||this.getState().selectedSession?.id!==t.id)return;if(me(t)&&_l(o)){await this.recreateCachedNewSession(t,i);return}this.setState({error:String(o)})}}async loadEarlierMessages(){const t=this.getState(),i=t.selectedSession;if(!(!i||t.isLoadingEarlierMessages||t.messagePageStart<=0)){this.setState({isLoadingEarlierMessages:!0});try{const s=await this.api.messages(i.id,{before:t.messagePageStart,limit:je});if(this.getState().selectedSession?.id!==i.id)return;const r=this.transcripts.mergeHistory(i.id,s);this.setState(r)}catch(s){this.setState({error:String(s)})}finally{this.getState().selectedSession?.id===i.id&&this.setState({isLoadingEarlierMessages:!1})}}}async send(t,i){if(t.trim().startsWith("/"))return this.runCommand(t);if(gl(t))return this.runShell(t);const r=this.getState().selectedSession;if(!(!r||r.archived===!0))try{await this.api.prompt(r.id,t,i),this.markCachedNewSessionPersisted(r)}catch(o){this.setState({error:String(o)})}}async runShell(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0)){this.setState({messages:[...this.getState().messages,oe("user",t)]});try{await this.api.shell(i.id,t),this.markCachedNewSessionPersisted(i)}catch(s){this.setState({messages:[...this.getState().messages,oe("system",String(s))],error:String(s)})}}}async runCommand(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0)){this.setState({messages:[...this.getState().messages,oe("user",t)]});try{this.applyCommandResult(await this.api.runCommand(i.id,t)),this.markCachedNewSessionPersisted(i)}catch(s){this.setState({messages:[...this.getState().messages,oe("system",String(s))],error:String(s)})}}}async respondToCommand(t,i){const s=this.getState().selectedSession;if(s){this.setState({commandDialog:void 0});try{this.applyCommandResult(await this.api.respondToCommand(s.id,t,i))}catch(r){this.setState({error:String(r)})}}}cancelCommand(){this.setState({commandDialog:void 0})}applySessionStatus(t){this.applyStatus(t)}async archiveSession(t=this.getState().selectedSession){if(t){if(me(t)){await this.deleteCachedNewSession(t);return}try{await this.api.archive(t.id);const i=this.getState(),s=Cl(i.sessions,t.id,new Date().toISOString()),r=Il(s,i.selectedSession?.id,t.id);this.setState({sessions:s}),r.type==="select"?await this.selectSession(r.session):r.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(i){this.setState({error:String(i)})}}}async archiveSessionWithDescendants(t=this.getState().selectedSession){if(!(!t||me(t)))try{const i=await this.api.archiveWithDescendants(t.id),s=i.sessionIds!==void 0&&i.sessionIds.length>0?i.sessionIds:[t.id],r=this.getState(),o=wr(r.sessions,s,new Date().toISOString()),n=yr(o,r.selectedSession?.id,s);this.setState({sessions:o}),n.type==="select"?await this.selectSession(n.session):n.type==="clear"&&this.deselectSession({forgetRememberedSelection:!0})}catch(i){this.setState({error:String(i)})}}async deleteCachedNewSession(t=this.getState().selectedSession){if(!me(t))return;this.api.stop(t.id).catch(()=>{}),us(t.id),yi(t.id);const i=this.getState().sessions.filter(r=>r.id!==t.id);if(this.setState({sessions:i}),this.getState().selectedSession?.id!==t.id)return;const s=i.find(r=>r.archived!==!0)??i[0];s!==void 0?await this.selectSession(s):(this.clearActiveSession(),this.updateUrl())}async restoreSession(t=this.getState().selectedSession){if(t)try{await this.api.restore(t.id);const i={...t};delete i.archived,delete i.archivedAt,this.replaceSession(i),this.getState().selectedSession?.id===i.id&&await this.selectSession(i)}catch(i){this.setState({error:String(i)})}}async detachParent(t=this.getState().selectedSession){if(t?.parentSessionPath!==void 0)try{await this.api.detachParent(t.id);const i={...t};delete i.parentSessionPath,this.replaceSession(i)}catch(i){this.setState({error:String(i)})}}async listModels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.models(t.id)).models}catch(i){return this.setState({error:String(i)}),[]}}async setModel(t,i){const s=this.getState().selectedSession;if(!(!s||s.archived===!0))try{this.applyStatus(await this.api.setModel(s.id,t,i))}catch(r){this.setState({error:String(r)})}}async cycleModel(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0))try{this.applyStatus(await this.api.cycleModel(i.id,t))}catch(s){this.setState({error:String(s)})}}async listThinkingLevels(){const t=this.getState().selectedSession;if(!t||t.archived===!0)return[];try{return(await this.api.thinkingLevels(t.id)).levels}catch(i){return this.setState({error:String(i)}),[]}}async setThinkingLevel(t){const i=this.getState().selectedSession;if(!(!i||i.archived===!0))try{this.applyStatus(await this.api.setThinkingLevel(i.id,t))}catch(s){this.setState({error:String(s)})}}async cycleThinkingLevel(){const t=this.getState().selectedSession;if(!(!t||t.archived===!0))try{this.applyStatus(await this.api.cycleThinkingLevel(t.id))}catch(i){this.setState({error:String(i)})}}async stopActiveWork(){const t=this.getState().selectedSession;if(t)try{await this.api.abort(t.id)}catch(i){this.setState({error:String(i)})}}async refreshSelectedSession(t=this.getState().selectedSession?.id){const i=this.getState().selectedSession;if(!(t===void 0||i?.id!==t||i.archived===!0))try{this.flushPendingTranscriptEvents();const[s,r]=await Promise.all([this.api.messages(t,{limit:je}),this.api.status(t)]);if(this.getState().selectedSession?.id!==t)return;const o=this.transcripts.mergeHistory(t,s);this.setState({...o,status:r,activity:this.getState().sessionActivities[t],isReceivingPartialStream:r.isStreaming}),this.applyStatus(r)}catch(s){this.getState().selectedSession?.id===t&&this.setState({error:String(s)})}}replaceSession(t){const i=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(s=>s.id===t.id?t:s),selectedSession:i?.id===t.id?t:i})}async recreateCachedNewSession(t,i){try{const s=await this.api.startSession(t.cwd);hs(s),Fa(t.id,s.id),us(t.id);const r=Xt(s);this.setState({sessions:[r,...this.getState().sessions.filter(o=>o.id!==t.id)],error:""}),await this.selectSession(r,{updateUrl:!1}),this.updateUrl(i?.updateUrl===!1?{replace:!0}:void 0)}catch(s){this.setState({error:String(s)})}}markCachedNewSessionPersisted(t){if(!me(t))return;const i=this.getState().sessions.find(s=>s.id===t.id)??t;this.replaceSession(fa(i))}applyCommandResult(t){if(t.type==="select"){this.setState({commandDialog:t});return}const i=(t.type==="unsupported",t.message);if(i!==void 0&&i!==""&&this.setState({messages:[...this.getState().messages,oe(t.type==="unsupported"?"system":"tool",i)]}),t.type==="done"&&t.session){t.promptDraft!==void 0&&bt(t.session.id,t.promptDraft);const s=this.getState().selectedSession,r=[t.session,...this.getState().sessions.filter(o=>o.id!==t.session?.id)];this.setState({sessions:r,selectedSession:s?.id===t.session.id?t.session:s}),s?.id!==t.session.id&&this.selectSession(t.session)}}applyActivity(t){this.setState({sessionActivities:{...this.getState().sessionActivities,[t.sessionId]:t},activity:this.getState().selectedSession?.id===t.sessionId?t:this.getState().activity})}applyStatus(t){const i=this.getState(),s=i.sessionActivities[t.sessionId]?.phase==="active"&&!At(t);this.setState({sessionStatuses:{...i.sessionStatuses,[t.sessionId]:t},...Ml(i,t.sessionId,t.messageCount),...s?{sessionActivities:Rl(i.sessionActivities,t.sessionId)}:{},status:i.selectedSession?.id===t.sessionId?t:i.status,activity:i.selectedSession?.id===t.sessionId&&s?void 0:i.activity}),this.catchupStreamSessionId===t.sessionId&&!t.isStreaming&&this.finishStreamCatchup(t.sessionId)}applySessionName(t,i){const s=o=>{if(o.id!==t)return o;const n={...o};return i===void 0||i===""?delete n.name:n.name=i,n},r=this.getState().selectedSession;this.setState({sessions:this.getState().sessions.map(s),selectedSession:r===void 0?void 0:s(r)})}applyEvent(t){const i=this.getState().selectedSession?.id;if(this.catchupStreamSessionId!==void 0&&this.catchupStreamSessionId===i){if(t.type==="message.end"||t.type==="agent.end"){this.finishStreamCatchup(this.catchupStreamSessionId);return}if(El(t))return}if(Dl(t)){this.queueTranscriptEvent(t);return}this.flushPendingTranscriptEvents();const s=this.transcripts.applyLiveEvent(this.getState().messages,t);s?this.setState({messages:s}):t.type==="status.update"?this.applyStatus(t.status):t.type==="activity.update"?this.applyActivity(t.activity):t.type==="session.name"&&this.applySessionName(t.sessionId,t.name)}queueTranscriptEvent(t){this.pendingTranscriptEvents.push(t),this.pendingTranscriptFrame===void 0&&(this.pendingTranscriptFrame=requestAnimationFrame(()=>{this.pendingTranscriptFrame=void 0,this.flushPendingTranscriptEvents()}))}flushPendingTranscriptEvents(){if(this.pendingTranscriptEvents.length===0)return;const t=this.pendingTranscriptEvents;this.pendingTranscriptEvents=[];let i=this.getState().messages;for(const s of t)i=this.transcripts.applyLiveEvent(i,s)??i;i!==this.getState().messages&&this.setState({messages:i})}clearPendingTranscriptEvents(){this.pendingTranscriptEvents=[],this.pendingTranscriptFrame!==void 0&&(cancelAnimationFrame(this.pendingTranscriptFrame),this.pendingTranscriptFrame=void 0)}finishStreamCatchup(t){this.catchupStreamSessionId===t&&(this.catchupStreamSessionId=void 0,this.getState().selectedSession?.id===t&&this.setState({isReceivingPartialStream:!1}),this.refreshMessages(t))}async refreshMessages(t){try{const i=await this.api.messages(t,{limit:je});if(this.getState().selectedSession?.id!==t)return;this.setState(this.transcripts.mergeHistory(t,i))}catch(i){this.getState().selectedSession?.id===t&&this.setState({error:String(i)})}}}function Rl(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function Ml(e,t,i){if(i===void 0)return{};const r=e.sessions.some(n=>n.id===t&&n.messageCount!==i)?e.sessions.map(n=>n.id===t?{...n,messageCount:i}:n):void 0,o=e.selectedSession?.id===t&&e.selectedSession.messageCount!==i?{...e.selectedSession,messageCount:i}:e.selectedSession;return{...r===void 0?{}:{sessions:r},...o!==e.selectedSession?{selectedSession:o}:{}}}function El(e){return["message.append","assistant.delta","assistant.thinking.delta","tool.start","tool.update","tool.end","shell.start","shell.chunk","shell.end","command.output","session.error"].includes(e.type)}function Dl(e){return e.type==="assistant.delta"||e.type==="assistant.thinking.delta"||e.type==="shell.chunk"}function _l(e){return e instanceof Error&&e.message.toLowerCase().includes("session not found")}class Ll{constructor(){this.workspaceIdsByProject=new Map}latestWorkspaceId(t){return this.workspaceIdsByProject.get(t)}rememberWorkspace(t){this.workspaceIdsByProject.set(t.projectId,t.id)}forgetProject(t){this.workspaceIdsByProject.delete(t)}}function Ol(e,t){const i=t?.targetWorkspaceId;if(i!==void 0&&i!=="")return e.find(r=>r.id===i);const s=t?.latestWorkspaceId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e[0]:e[0]}class Wl{constructor(t,i,s,r,o=new Ll,n={}){this.getState=t,this.setState=i,this.updateUrl=s,this.sessions=r,this.workspaceSelection=o,this.api=n.api??j}clearSelection(t){this.sessions.clearActiveSession(),this.setState({selectedProject:void 0,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!1,...Ft()}),t?.updateUrl!==!1&&this.updateUrl()}forgetProject(t){this.workspaceSelection.forgetProject(t);const i=Object.fromEntries(Object.entries(this.getState().workspacesByProjectId).filter(([s])=>s!==t));this.setState({workspacesByProjectId:i})}async selectProject(t,i){this.sessions.clearActiveSession(),this.setState({selectedProject:t,selectedWorkspace:void 0,workspaces:[],isLoadingWorkspaces:!0,...Ft()});try{const s=await this.api.workspaces(t.id);this.setState({workspaces:s,workspacesByProjectId:{...this.getState().workspacesByProjectId,[t.id]:s},isLoadingWorkspaces:!1});const r=Ol(s,{targetWorkspaceId:i?.workspaceId,latestWorkspaceId:this.workspaceSelection.latestWorkspaceId(t.id)});r?await this.selectWorkspace(r,{sessionId:i?.sessionId,updateUrl:i?.updateUrl}):i?.updateUrl!==!1&&this.updateUrl()}catch(s){this.setState({error:String(s),isLoadingWorkspaces:!1})}}async selectWorkspace(t,i){this.workspaceSelection.rememberWorkspace(t),this.sessions.clearActiveSession(),this.setState({selectedWorkspace:t,isLoadingWorkspaces:!1,...Ft()});try{const s=ua(t.path,await this.api.sessions(t.path));this.setState({sessions:s});const r=this.sessions.preferredSession(t.path,s,i?.sessionId);r?await this.sessions.selectSession(r,{updateUrl:i?.updateUrl}):i?.updateUrl!==!1&&this.updateUrl()}catch(s){this.setState({error:String(s)})}}async refreshProjectWorkspaces(t){const i=this.getState().projects.find(r=>r.id===t);if(i===void 0)throw new Error("Project not found");const s=await this.api.workspaces(i.id);return this.applyProjectWorkspaces(i.id,s),s}async refreshAfterWorkspaceDeleted(t,i){const s=await this.refreshProjectWorkspaces(t),r=this.getState();if(r.selectedProject?.id!==t||r.selectedWorkspace?.id!==i)return;const o=Nl(s);o!==void 0?await this.selectWorkspace(o):this.clearSelection()}applyProjectWorkspaces(t,i){const s=this.getState(),r={...s.workspacesByProjectId,[t]:i};s.selectedProject?.id===t?this.setState({workspaces:i,workspacesByProjectId:r}):this.setState({workspacesByProjectId:r})}}function jl(e){return e!==void 0&&e.isGitWorktree&&!e.isMain}function Nl(e){return e.find(t=>t.isMain)??e[0]}class Fl{constructor(){this.terminalIdsByCwd=new Map}latestTerminalId(t){return this.terminalIdsByCwd.get(t)}rememberTerminal(t,i){this.terminalIdsByCwd.set(t,i)}forgetWorkspace(t){this.terminalIdsByCwd.delete(t)}forgetTerminal(t){for(const[i,s]of this.terminalIdsByCwd.entries())s===t&&this.terminalIdsByCwd.delete(i)}}function Iu(e,t){const i=t?.targetTerminalId;if(i!==void 0&&i!=="")return e.find(r=>r.id===i);const s=t?.latestTerminalId;return s!==void 0&&s!==""?e.find(r=>r.id===s)??e.find(r=>!r.exited)??e[0]:e.find(r=>!r.exited)??e[0]}function Au(e){return e.find(t=>!t.exited)??e[0]}const Bl=1200;class zl{constructor(){this.pendingTokens=[]}handle(t,i){const s=Hl(t);if(s===void 0||!ys(s))return!1;const r=i.filter(l=>l.shortcut!==void 0&&l.enabled!==!1).map(l=>({action:l,tokens:xr(l.shortcut??"")})).filter(l=>l.tokens.length>0),o=this.pendingTokens.length>0&&!ys(s)?[...this.pendingTokens,s]:[s],n=r.find(l=>Vl(l.tokens,o));return n!==void 0?(this.clearPending(),n.action.run(),!0):r.some(l=>kr(l.tokens,o))?(this.setPending(o),!0):(this.clearPending(),!1)}reset(){this.clearPending()}setPending(t){this.clearPending(),this.pendingTokens=t,this.pendingTimer=window.setTimeout(()=>{this.pendingTokens=[],this.pendingTimer=void 0},Bl)}clearPending(){this.pendingTokens=[],this.pendingTimer!==void 0&&(window.clearTimeout(this.pendingTimer),this.pendingTimer=void 0)}}function ql(e){return xr(e).map(t=>t.split("+").map(i=>i==="mod"?xs()?"⌘":"Ctrl":i==="shift"?"Shift":i==="alt"?xs()?"⌥":"Alt":i==="ctrl"?"Ctrl":i==="enter"?"Enter":i==="escape"?"Esc":i==="."?".":i.length===1?i.toUpperCase():`${i.charAt(0).toUpperCase()}${i.slice(1)}`).join("+")).join(" ")}function Hl(e){if(e.isComposing)return;const t=Ul(e.key);if(t===void 0)return;const i=[];return(e.metaKey||e.ctrlKey)&&i.push("mod"),e.altKey&&i.push("alt"),e.shiftKey&&i.push("shift"),i.push(t),i.join("+")}function xr(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t!=="").map(t=>t.split("+").filter(i=>i!=="").join("+"))}function Ul(e){if(e===" ")return"space";if(e.length===1)return e.toLowerCase();const t=e.toLowerCase();if(["enter","escape","tab","arrowup","arrowdown","arrowleft","arrowright","backspace","delete"].includes(t))return t}function Vl(e,t){return e.length===t.length&&kr(e,t)}function kr(e,t){return t.every((i,s)=>e[s]===i)}function ys(e){return e.includes("+")}function xs(){return navigator.userAgent.toLowerCase().includes("mac")}const Si="themes:classic",Gl="themes:pi-web-dark",Kl={themeId:Gl,auto:!0},Sr="pi-web-app-theme",Ql=["--pi-bg","--pi-surface","--pi-surface-hover","--pi-terminal-bg","--pi-terminal-text","--pi-border","--pi-border-muted","--pi-text","--pi-text-secondary","--pi-text-bright","--pi-muted","--pi-dim","--pi-accent","--pi-accent-border","--pi-selection-bg","--pi-success","--pi-success-border","--pi-success-bg","--pi-success-surface","--pi-success-ring","--pi-warning","--pi-warning-border","--pi-warning-surface","--pi-danger","--pi-purple","--pi-purple-border","--pi-purple-surface","--pi-overlay","--pi-shadow-soft","--pi-shadow","--pi-shadow-strong","--pi-bg-overlay-soft","--pi-bg-overlay","--pi-success-bg-overlay","--pi-terminal-selection"],Jl=/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u;function Zl(){try{const e=window.localStorage.getItem(Sr);return e===null?void 0:ic(e)}catch{return}}function Xl(e){try{window.localStorage.setItem(Sr,JSON.stringify(e))}catch{}}function Yl(e){const t=document.documentElement;t.dataset.piWebTheme=e.id,t.style.colorScheme=e.colorScheme;for(const i of Ql){const s=e.tokens[i];typeof s=="string"&&s!==""?t.style.setProperty(i,s):t.style.removeProperty(i)}}function ec(e){const t=tc(e.themes,e.fallbackThemeId??Si),i=e.themes.find(n=>n.id===e.preference.themeId)??t;if(i===void 0)return{selectedTheme:void 0,activeTheme:void 0,selectedThemePair:void 0,fallbackTheme:t};const s=$r(e.themePairs,i.id);if(!e.preference.auto||s===void 0)return{selectedTheme:i,activeTheme:i,selectedThemePair:s,fallbackTheme:t};const r=e.prefersLight?s.light:s.dark,o=e.themes.find(n=>n.id===r)??i;return{selectedTheme:i,activeTheme:o,selectedThemePair:s,fallbackTheme:t}}function tc(e,t=Si){return e.find(i=>i.id===t)??e[0]}function $r(e,t){return e.find(i=>i.light===t||i.dark===t)}function ic(e){const t=e.trim();if(t!=="")try{const i=JSON.parse(t);return sc(i)?i:void 0}catch{return}}function sc(e){if(!rc(e))return!1;const t=e.themeId,i=e.auto;return oc(t)&&typeof i=="boolean"}function rc(e){return typeof e=="object"&&e!==null}function oc(e){return typeof e=="string"&&Jl.test(e)}const Pr="workspace.delete",Tr="pi.operation",Cr="target.workspaceId",nc="target.workspacePath";function ac(e){return{[Tr]:Pr,[Cr]:e.id,[nc]:e.path}}function lc(e){return{...e===void 0?{}:{projectId:e},metadata:{[Tr]:Pr}}}function cc(e){const t={};for(const i of e){const s=ti(i);if(s===void 0)continue;const r=t[s];(r===void 0||i.createdAt.localeCompare(r.createdAt)>=0)&&(t[s]=i)}return t}function dc(e){return Object.entries(e).filter(([,t])=>xt(t)).map(([t])=>t)}function Ir(e,t){if(t===void 0)return!1;const i=e.workspaceDeletionRuns[t.id];return i!==void 0&&xt(i)}function ti(e){return e.metadata[Cr]}function xt(e){return e.status==="queued"||e.status==="running"}function pc(){return[{id:"actions.show",title:"Show Actions",description:"Open the command palette",shortcut:"mod+k",group:"General",run:e=>{e.openActionPalette()}},{id:"prompt.focus",title:"Focus Prompt",description:"Move keyboard focus to the message composer",group:"General",enabled:e=>e.state.selectedSession!==void 0,run:e=>{e.focusPrompt()}},{id:"project.add",title:"Add Project",group:"Project",run:e=>e.addProject()},{id:"auth.login",title:"Configure Provider Authentication",description:"Run /login without tying authentication to a session",group:"General",run:e=>e.configureAuth()},{id:"auth.logout",title:"Remove Provider Authentication",description:"Run /logout for stored pi credentials",group:"General",run:e=>e.logoutAuth()},{id:"theme.select",title:"Select Theme",description:"Choose the PI WEB color theme",group:"Preferences",run:e=>{e.openThemePicker()}},{id:"app.refresh-data",title:"Refresh App Data",description:"Refresh session, status, activity, and the current workspace surface without reloading the page",group:"General",run:e=>e.refreshAppData()},{id:"app.reload-page",title:"Full Page Reload",description:"Reload the PI WEB browser page",group:"General",run:e=>{e.reloadPage()}},{id:"view.chat",title:"Go to Chat",shortcut:"mod+1",group:"Navigation",run:e=>{e.selectMainView("chat")}},{id:"view.files",title:"Go to Files",shortcut:"mod+2",group:"Navigation",enabled:Ne,run:e=>{e.selectMainView("core:workspace.files")}},{id:"view.git",title:"Go to Git",shortcut:"mod+3",group:"Navigation",enabled:ks,run:e=>{e.selectMainView("core:workspace.git")}},{id:"view.terminal",title:"Go to Terminal",shortcut:"mod+4",group:"Navigation",enabled:Ne,run:e=>{e.selectMainView("core:workspace.terminal")}},{id:"workspace.refresh-files",title:"Refresh Files",shortcut:"mod+shift+f",group:"Workspace",enabled:Ne,run:e=>e.refreshFiles()},{id:"workspace.refresh-git",title:"Refresh Git",shortcut:"mod+shift+g",group:"Workspace",enabled:ks,run:e=>e.refreshGit()},{id:"workspace.refresh-current",title:"Refresh Current Panel",shortcut:"mod+shift+r",group:"Workspace",enabled:Ne,run:e=>e.state.workspaceTool==="core:workspace.git"&&e.state.selectedWorkspace?.isGitRepo===!0?e.refreshGit():e.refreshFiles()},{id:"workspace.delete",title:"Delete Workspace",description:"Remove the selected Git worktree",group:"Workspace",enabled:hc,run:e=>e.deleteWorkspace()},{id:"session.start",title:"Start Session",shortcut:"mod+enter",group:"Session",enabled:Ne,run:e=>e.startSession()},{id:"session.archive",title:"Archive Session",description:"Archive the selected session",group:"Session",enabled:e=>e.state.selectedSession!==void 0&&e.state.selectedSession.archived!==!0,run:e=>e.archiveSession()},{id:"session.stop",title:"Stop Active Work",shortcut:"mod+.",group:"Session",enabled:e=>e.state.selectedSession!==void 0&&At(e.state.status,e.state.activity),run:e=>e.stopActiveWork()}]}function Ne(e){return e.state.selectedWorkspace!==void 0}function ks(e){return e.state.selectedWorkspace?.isGitRepo===!0}function hc(e){const t=e.state.selectedWorkspace;return t!==void 0&&t.isGitWorktree&&!t.isMain&&!Ir(e.state,t)}const uc="modulepreload",fc=function(e){return"/"+e},Ss={},Ar=function(t,i,s){let r=Promise.resolve();if(i&&i.length>0){let l=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const n=document.querySelector("meta[property=csp-nonce]"),a=n?.nonce||n?.getAttribute("nonce");r=l(i.map(d=>{if(d=fc(d),d in Ss)return;Ss[d]=!0;const u=d.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":uc,u||(f.as="script"),f.crossOrigin="",f.href=d,a&&f.setAttribute("nonce",a),document.head.appendChild(f),u)return new Promise((g,v)=>{f.addEventListener("load",g),f.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(n){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=n,window.dispatchEvent(a),!a.defaultPrevented)throw n}return r.then(n=>{for(const a of n||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},mc=10*1024*1024,gc="10 MB";function vc(){return[{id:"workspace.files",title:"Files",order:10,render:bc},{id:"workspace.git",title:"Git",order:20,visible:({workspace:e})=>e.isGitRepo,render:Sc},{id:"workspace.terminal",title:"Terminal",order:30,badge:e=>e.activeTerminalCount>0?e.activeTerminalCount:void 0,render:kc}]}function bc(e){return c`
|
|
21
|
+
<section class="toolbar">
|
|
22
|
+
<strong>Files</strong>
|
|
23
|
+
${e.fileTreeStale?c`<span class="stale">stale</span>`:null}
|
|
24
|
+
<button @click=${e.onRefreshFiles}>Refresh</button>
|
|
25
|
+
</section>
|
|
26
|
+
<section class="split">
|
|
27
|
+
<div class="list tree">
|
|
28
|
+
${e.fileTree.length===0?c`<p class="muted">No files loaded.</p>`:e.fileTree.map(t=>Rr(e,t,0))}
|
|
29
|
+
</div>
|
|
30
|
+
<div class="viewer">
|
|
31
|
+
${yc(e)}
|
|
32
|
+
</div>
|
|
33
|
+
</section>
|
|
34
|
+
`}function Rr(e,t,i){const s=e.expandedDirs[t.path],r=s!==void 0,o=t.type!=="directory"&&e.selectedFilePath===t.path;return c`
|
|
35
|
+
<button class=${o?"row selected":"row"} style=${`--depth:${String(i)}`} @click=${()=>{wc(e,t)}}>
|
|
36
|
+
<span>${t.type==="directory"?r?"▾":"▸":"·"}</span>
|
|
37
|
+
<span>${t.name}</span>
|
|
38
|
+
</button>
|
|
39
|
+
${r?s.map(n=>Rr(e,n,i+1)):null}
|
|
40
|
+
`}function wc(e,t){t.type==="directory"?e.onExpandDir(t.path):e.onSelectFile(t.path)}function yc(e){const t=e.selectedFileContent;return e.selectedFilePath===void 0||e.selectedFilePath===""?c`<p class="muted">Select a file.</p>`:t===void 0?c`<p class="muted">Loading ${e.selectedFilePath}…</p>`:t.mediaType==="image"?xc(e,t):t.binary?c`<p class="muted">Binary file: ${t.path} · ${ii(t.size)}</p>`:(Mr(),c`
|
|
41
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${t.language??"text"}${t.truncated?" · truncated":""}</small></div>
|
|
42
|
+
<code-viewer .content=${t.content} .language=${t.language}></code-viewer>
|
|
43
|
+
`)}function xc(e,t){const i=`${t.mimeType??"image"} · ${ii(t.size)}`;if(t.size>mc)return c`
|
|
44
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${i}</small></div>
|
|
45
|
+
<p class="muted">Image too large to preview: ${ii(t.size)} · limit ${gc}</p>
|
|
46
|
+
`;const s=Bn(e.workspace.projectId,e.workspace.id,t.path,{modifiedAt:t.modifiedAt});return c`
|
|
47
|
+
<div class="viewer-header"><strong>${t.path}</strong><small>${i}</small></div>
|
|
48
|
+
<div class="image-preview">
|
|
49
|
+
<img src=${s} alt=${t.path} decoding="async" />
|
|
50
|
+
</div>
|
|
51
|
+
`}function kc(e){return Tc(),c`<terminal-panel .workspace=${e.workspace} .selectedTerminalId=${e.selectedTerminalId} .autoStart=${e.terminalAutoStart} .onSelectTerminal=${e.onSelectTerminal}></terminal-panel>`}function Sc(e){const t=e.gitStatus;return c`
|
|
52
|
+
<section class="toolbar">
|
|
53
|
+
<strong>Git</strong>
|
|
54
|
+
${e.gitStale?c`<span class="stale">stale</span>`:null}
|
|
55
|
+
<button @click=${e.onRefreshGit}>Refresh</button>
|
|
56
|
+
</section>
|
|
57
|
+
<section class="split">
|
|
58
|
+
<div class="list">
|
|
59
|
+
${t===void 0?c`<p class="muted">No status loaded.</p>`:t.isGitRepo?c`
|
|
60
|
+
<p class="summary">${Cc(t)}</p>
|
|
61
|
+
${t.files.length===0?c`<p class="muted">No changes.</p>`:t.files.map(i=>c`
|
|
62
|
+
<button class="row ${e.selectedDiffPath===i.path?"selected":""}" @click=${()=>{e.onSelectDiff(i.path)}}>
|
|
63
|
+
<span>${Ic(i.index,i.workingTree)}</span>
|
|
64
|
+
<span>${i.path}</span>
|
|
65
|
+
</button>
|
|
66
|
+
`)}
|
|
67
|
+
`:c`<p class="muted">Not a git repository.</p>`}
|
|
68
|
+
</div>
|
|
69
|
+
<div class="viewer">
|
|
70
|
+
${$c(e)}
|
|
71
|
+
</div>
|
|
72
|
+
</section>
|
|
73
|
+
`}function $c(e){if(e.selectedDiffPath===void 0||e.selectedDiffPath==="")return c`<p class="muted">Select a changed file.</p>`;const t=e.selectedDiff,i=e.selectedStagedDiff;if(t===void 0||i===void 0)return c`<p class="muted">Loading diff…</p>`;const s=[i,t].filter(r=>r.diff!=="");return s.length===0?c`<p class="muted">No staged or unstaged diff.</p>`:c`
|
|
74
|
+
<div class=${s.length===1?"diffs single":"diffs"}>
|
|
75
|
+
${s.map(r=>Pc(r))}
|
|
76
|
+
</div>
|
|
77
|
+
`}function Pc(e){return Mr(),c`
|
|
78
|
+
<section class="diff-section">
|
|
79
|
+
<div class="viewer-header"><strong>${e.path??"diff"}</strong><small>${e.staged?"staged":"unstaged"}${e.truncated?" · truncated":""}</small></div>
|
|
80
|
+
<code-viewer .content=${e.diff} .language=${"diff"}></code-viewer>
|
|
81
|
+
</section>
|
|
82
|
+
`}function Mr(){Ar(()=>import("./CodeViewer-kpPA8xEx.js"),__vite__mapDeps([0,1,2,3]))}function Tc(){Ar(()=>import("./TerminalPanel-Do-9K9_u.js"),__vite__mapDeps([4,5,6,1,2]))}function Cc(e){const t=e.branch??"detached",i=e.ahead??0,s=e.behind??0;return i===0&&s===0?t:`${t} · ↑${String(i)} ↓${String(s)}`}function Ic(e,t){return(t!=="unmodified"?t:e).slice(0,1).toUpperCase()}function ii(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${String(e)} B`;const t=e/1024;if(t<1024)return`${zt(t)} KB`;const i=t/1024;return i<1024?`${zt(i)} MB`:`${zt(i/1024)} GB`}function zt(e){return e>=10?String(Math.round(e)):e.toFixed(1)}const Ac={apiVersion:1,name:"PI WEB Core",activate:()=>({contributions:{actions:pc(),workspacePanels:vc()}})},Rc={"--pi-bg":"#0d1117","--pi-surface":"#161b22","--pi-surface-hover":"#21262d","--pi-terminal-bg":"#05070a","--pi-terminal-text":"#e6edf3","--pi-border":"#30363d","--pi-border-muted":"#21262d","--pi-text":"#e6edf3","--pi-text-secondary":"#c9d1d9","--pi-text-bright":"#f0f6fc","--pi-muted":"#8b949e","--pi-dim":"#6e7681","--pi-accent":"#58a6ff","--pi-accent-border":"#2f81f7","--pi-selection-bg":"#0d2847","--pi-success":"#3fb950","--pi-success-border":"#238636","--pi-success-bg":"#0f1b12","--pi-success-surface":"#0f2a16","--pi-success-ring":"#3fb95055","--pi-warning":"#d29922","--pi-warning-border":"#6e5200","--pi-warning-surface":"#1f1a10","--pi-danger":"#ff7b72","--pi-purple":"#d2a8ff","--pi-purple-border":"#a371f7","--pi-purple-surface":"#21132f","--pi-overlay":"#0008","--pi-shadow-soft":"#0006","--pi-shadow":"#0008","--pi-shadow-strong":"#000b","--pi-bg-overlay-soft":"#0d1117dd","--pi-bg-overlay":"#0d1117e6","--pi-success-bg-overlay":"#0f1b12ee","--pi-terminal-selection":"#264f78"},Mc={"--pi-bg":"#070912","--pi-surface":"#101527","--pi-surface-hover":"#151b31","--pi-terminal-bg":"#050710","--pi-terminal-text":"#f7f4ff","--pi-border":"#26304f","--pi-border-muted":"#26304f","--pi-text":"#f7f4ff","--pi-text-secondary":"#aaa4bd","--pi-text-bright":"#ffffff","--pi-muted":"#aaa4bd","--pi-dim":"#817a99","--pi-accent":"#7c3cff","--pi-accent-border":"#3d4a78","--pi-selection-bg":"#151b31","--pi-success":"#00f0d8","--pi-success-border":"#00f0d8","--pi-success-bg":"#071e22","--pi-success-surface":"#092d31","--pi-success-ring":"#00f0d855","--pi-warning":"#ffb000","--pi-warning-border":"#ffb000","--pi-warning-surface":"#16140d","--pi-danger":"#ff4f7b","--pi-purple":"#b7a2ff","--pi-purple-border":"#7c3cff","--pi-purple-surface":"#181026","--pi-overlay":"#0008","--pi-shadow-soft":"#0006","--pi-shadow":"#0008","--pi-shadow-strong":"#000b","--pi-bg-overlay-soft":"#070912dd","--pi-bg-overlay":"#070912e6","--pi-success-bg-overlay":"#071e22ee","--pi-terminal-selection":"#3d4a78"},Ec={"--pi-bg":"#f7f1e6","--pi-surface":"#fff9ee","--pi-surface-hover":"#f0e6d6","--pi-terminal-bg":"#15131b","--pi-terminal-text":"#fff9ee","--pi-border":"#c9bca8","--pi-border-muted":"#d8cdbc","--pi-text":"#15131b","--pi-text-secondary":"#15131b","--pi-text-bright":"#15131b","--pi-muted":"#5f586a","--pi-dim":"#766f7e","--pi-accent":"#6430d8","--pi-accent-border":"#6430d8","--pi-selection-bg":"#eadff8","--pi-success":"#008c82","--pi-success-border":"#008c82","--pi-success-bg":"#e1f4ef","--pi-success-surface":"#d7f0ec","--pi-success-ring":"#008c8255","--pi-warning":"#b05f00","--pi-warning-border":"#b05f00","--pi-warning-surface":"#fff2d2","--pi-danger":"#b51d49","--pi-purple":"#6430d8","--pi-purple-border":"#6430d8","--pi-purple-surface":"#eadff8","--pi-overlay":"#15131b66","--pi-shadow-soft":"#15131b22","--pi-shadow":"#15131b33","--pi-shadow-strong":"#15131b44","--pi-bg-overlay-soft":"#f7f1e6dd","--pi-bg-overlay":"#f7f1e6e6","--pi-success-bg-overlay":"#e1f4efee","--pi-terminal-selection":"#8d7b64"},Dc={apiVersion:1,name:"PI WEB Themes",activate:()=>({contributions:{themes:[{id:"pi-web-dark",name:"PI WEB Dark",description:"Dark PI WEB palette.",order:10,colorScheme:"dark",tokens:Mc},{id:"pi-web-light",name:"PI WEB Light",description:"Light PI WEB palette.",order:20,colorScheme:"light",tokens:Ec},{id:"classic",name:"PI WEB Classic",description:"The original PI WEB dark palette.",order:30,colorScheme:"dark",tokens:Rc}],themePairs:[{id:"pi-web",name:"PI WEB",description:"Follow the system light/dark preference with PI WEB themes.",order:10,light:"pi-web-light",dark:"pi-web-dark"}]}})};async function _c(e="/pi-web-plugins/manifest.json"){const t=await Lc(e);if(t===void 0)return[];const i=[];for(const s of t.plugins)try{const r=new URL(s.module,new URL(e,window.location.href)).toString(),o=await import(r),n=Wc(o,r);i.push({id:s.id,plugin:n})}catch(r){console.warn(`Failed to load PI WEB plugin ${s.module}`,r)}return i}async function Lc(e){const t=await fetch(e,{cache:"no-store"});if(t.status!==404){if(!t.ok)throw new Error(`Failed to load plugin manifest: ${t.statusText}`);return Oc(await t.json())}}function Oc(e){if(!kt(e)||!Array.isArray(e.plugins))throw new Error("Invalid plugin manifest");return{plugins:e.plugins.map(t=>{if(!kt(t)||typeof t.id!="string"||t.id===""||typeof t.module!="string"||t.module==="")throw new Error("Invalid plugin manifest entry");return{id:t.id,module:t.module}})}}function Wc(e,t){if(!kt(e))throw new Error(`Plugin module ${t} did not export an object`);const i=e.default;if(!jc(i))throw new Error(`Plugin module ${t} default export is not a PiWebPlugin`);return i}function jc(e){return kt(e)&&e.apiVersion===1&&typeof e.name=="string"&&typeof e.activate=="function"}function kt(e){return typeof e=="object"&&e!==null}const Nc=/^[a-z][a-z0-9.-]*$/u,Fc=/^[a-z][a-z0-9.-]*$/u,Er=new WeakMap,Dr=new WeakMap;class Bc{constructor(){this.actions=[],this.workspacePanels=[],this.workspaceLabels=[],this.themes=[],this.themePairs=[],this.pluginIds=new Set,this.contributionIds=new Set}register(t){const{id:i,plugin:s}=t;if(this.validatePluginId(i),this.pluginIds.has(i))throw new Error(`Duplicate plugin id: ${i}`);this.pluginIds.add(i);const r=s.apiVersion;if(r!==1)throw new Error(`Unsupported plugin API version for ${i}: ${String(r)}`);const n=s.activate({apiVersion:1,pluginId:i,html:c}).contributions;for(const a of n.actions??[])this.actions.push(this.qualifyAction(i,a));for(const a of n.workspacePanels??[])this.workspacePanels.push(this.qualifyWorkspacePanel(i,a));for(const a of n.workspaceLabels??[])this.workspaceLabels.push(this.qualifyWorkspaceLabelContribution(i,a));for(const a of n.themes??[])this.themes.push(this.qualifyTheme(i,a));for(const a of n.themePairs??[])this.themePairs.push(this.qualifyThemePair(i,a))}getActions(t){return this.actions.map(i=>{const s=zc(t,i.pluginId),r=i.enabled?.(s),o={id:i.id,pluginId:i.pluginId,localId:i.localId,title:i.title,run:()=>i.run(s)};return i.description!==void 0&&(o.description=i.description),i.shortcut!==void 0&&(o.shortcut=i.shortcut),i.group!==void 0&&(o.group=i.group),r!==void 0&&(o.enabled=r),o})}getWorkspacePanels(){return[...this.workspacePanels].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.title.localeCompare(i.title))}getThemes(){return[...this.themes].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.name.localeCompare(i.name))}getThemePairs(){return[...this.themePairs].sort((t,i)=>(t.order??1e3)-(i.order??1e3)||t.name.localeCompare(i.name))}getWorkspaceLabelItems(t,i){const s={state:t,workspace:i};return[...this.workspaceLabels].sort((r,o)=>(r.order??1e3)-(o.order??1e3)||r.id.localeCompare(o.id)).flatMap(r=>r.visible?.(s)===!1?[]:r.items(s))}qualifyAction(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id}}qualifyWorkspacePanel(t,i){const s=this.qualify(t,i.id),r=i.badge;return{...i,id:s,pluginId:t,localId:i.id,...r===void 0?{}:{badge:o=>r($s(o,t))},render:o=>i.render($s(o,t))}}qualifyWorkspaceLabelContribution(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id}}qualifyTheme(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id}}qualifyThemePair(t,i){const s=this.qualify(t,i.id);return{...i,id:s,pluginId:t,localId:i.id,light:this.qualifyReference(t,i.light),dark:this.qualifyReference(t,i.dark)}}qualify(t,i){this.validateLocalId(i);const s=`${t}:${i}`;if(this.contributionIds.has(s))throw new Error(`Duplicate contribution id: ${s}`);return this.contributionIds.add(s),s}qualifyReference(t,i){return this.validateLocalId(i),`${t}:${i}`}validatePluginId(t){if(!Nc.test(t))throw new Error(`Invalid plugin id: ${t}`)}validateLocalId(t){if(!Fc.test(t))throw new Error(`Invalid contribution id: ${t}`)}}function zc(e,t){return Er.get(e)?.(t)??e}function $s(e,t){return Dr.get(e)?.(t)??e}function qc(e,t){return Er.set(e,t),e}function Hc(e,t){return Dr.set(e,t),e}const Uc=["(display-mode: standalone)","(display-mode: fullscreen)","(display-mode: minimal-ui)"];function Vc(){return typeof window>"u"||!("matchMedia"in window)?[]:Uc.map(e=>window.matchMedia(e))}function Ps(e,t=Gc()){return e.some(i=>i.matches)||Kc(t)}function Gc(){return typeof navigator>"u"?void 0:navigator}function Kc(e){return e!==void 0&&"standalone"in e&&e.standalone===!0}function Qc(){const e=new URLSearchParams(window.location.search);return{projectId:e.get("project")??void 0,workspaceId:e.get("workspace")??void 0,sessionId:e.get("session")??void 0,tool:Zc(e.get("tool")),view:Xc(e.get("view"))}}function Jc(e,t){const i=new URL(window.location.href);i.searchParams.delete("project"),i.searchParams.delete("workspace"),i.searchParams.delete("session"),i.searchParams.delete("tool"),i.searchParams.delete("view"),e.projectId!==void 0&&e.projectId!==""&&i.searchParams.set("project",e.projectId),e.workspaceId!==void 0&&e.workspaceId!==""&&i.searchParams.set("workspace",e.workspaceId),e.sessionId!==void 0&&e.sessionId!==""&&i.searchParams.set("session",e.sessionId),e.tool!==void 0&&i.searchParams.set("tool",e.tool),e.view!==void 0&&i.searchParams.set("view",e.view);const s=`${i.pathname}${i.search}${i.hash}`,r=`${window.location.pathname}${window.location.search}${window.location.hash}`;s!==r&&(t?.replace===!0?window.history.replaceState({},"",i):window.history.pushState({},"",i))}function Zc(e){return e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":_r(e)?e:void 0}function Xc(e){return e==="chat"?"chat":e==="files"?"core:workspace.files":e==="git"?"core:workspace.git":_r(e)?e:void 0}function _r(e){return e!==null&&/^[a-z][a-z0-9.-]*:[a-z][a-z0-9.-]*$/u.test(e)}function Yc(e,t){const i=t.api??fi,s=t.pollIntervalMs??1e3,r=t.setTimeout??td(),o=t.clearTimeout??id();return{async runCommand(n){const a=await i.runTerminalCommand(e,n);return n.open===!0&&t.openTerminal(n.workspace,{terminalId:a.terminalId}),{run:a,completed:ed(a,i,s,r,o)}},listCommandRuns:n=>i.listCommandRuns(n),getCommandRun:n=>i.getCommandRun(n),open:n=>{t.openTerminal(void 0,n)}}}function ed(e,t,i,s,r){return Ts(e)?Promise.resolve(e):new Promise((o,n)=>{let a,l=!1;const d=f=>{l||(l=!0,a!==void 0&&r(a),o(f))},u=f=>{l||(l=!0,a!==void 0&&r(a),n(f instanceof Error?f:new Error(String(f))))},p=()=>{t.getCommandRun(e.id).then(f=>{if(f!==void 0&&Ts(f)){d(f);return}a=s(p,i)}).catch(u)};a=s(p,i)})}function Ts(e){return e.status==="succeeded"||e.status==="failed"}function td(){return(e,t)=>globalThis.setTimeout(e,t)}function id(){return e=>{globalThis.clearTimeout(e)}}function sd(e,t){return t[e.path]}function rd(e){if(e?.hasSessionActivity===!0)return"session";if(e?.hasTerminalActivity===!0)return"terminal"}function od(e,t,i){const s=nd(e,t,i);if(s.some(r=>r.hasSessionActivity))return"session";if(s.some(r=>r.hasTerminalActivity))return"terminal"}function nd(e,t,i){const s=new Set(t.filter(o=>o.projectId===e.id).map(o=>o.path)),r=new Map;for(const o of s){const n=i[o];n!==void 0&&r.set(n.cwd,n)}for(const o of Object.values(i))(o.cwd===e.path||o.cwd.startsWith(`${e.path}/`))&&r.set(o.cwd,o);return[...r.values()]}const rt=0,ad=120;function Mt(e){if(typeof HTMLElement>"u"||typeof window>"u"||!(e instanceof HTMLElement))return"";const t=e.getBoundingClientRect(),i=ld(e),s=window.innerWidth,r=window.innerHeight,o=Math.max(0,i.left),n=Math.min(s,i.right),a=Math.max(0,i.top),l=Math.min(r,i.bottom),d=Math.min(t.right,n),u=l-t.bottom-rt,p=t.top-a-rt;return[...u<ad&&p>u?[`bottom: ${Ce(r-t.top+rt)};`,`max-height: ${Ce(Math.max(0,p))};`]:[`top: ${Ce(t.bottom+rt)};`,`max-height: ${Ce(Math.max(0,u))};`],`right: ${Ce(Math.max(0,s-d))};`,`max-width: ${Ce(Math.max(0,d-o))};`].join(" ")}function ld(e){const t=e.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host.getBoundingClientRect():{top:0,right:window.innerWidth,bottom:window.innerHeight,left:0}}function Ce(e){return`${String(Math.round(e))}px`}function $i(e,t="Active"){if(e!==void 0)return c`<span class=${`activity-indicator ${e}`} role="img" aria-label=${t} title=${t}></span>`}const cd=["a[href]","button","input","select","textarea","summary","[role='button']","[role='link']","[contenteditable='true']"].join(",");function Lr(e){return e.composedPath().some(t=>dd(t,cd))}function dd(e,t){if(typeof Element<"u"&&e instanceof Element)return e.matches(t);if(!("matches"in e))return!1;const{matches:i}=e;return typeof i=="function"&&i.call(e,t)===!0}function Pi(e,t){Lr(e)||t()}function Ti(e,t){e.key!=="Enter"&&e.key!==" "||Lr(e)||(e.preventDefault(),t())}const pd=V`
|
|
83
|
+
:host { position: fixed; top: 0; right: 0; left: 0; display: block; height: 100dvh; box-sizing: border-box; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); color: var(--pi-text); background: var(--pi-bg); font: 14px system-ui, sans-serif; }
|
|
84
|
+
.shell { --navigation-panel-width: 340px; --workspace-panel-width: minmax(360px, 42vw); display: grid; grid-template-columns: var(--navigation-panel-width) 1px minmax(420px, 1fr) 1px var(--workspace-panel-width); height: 100%; min-height: 0; }
|
|
85
|
+
aside { grid-column: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
86
|
+
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); }
|
|
87
|
+
.header-actions { display: flex; align-items: center; gap: 8px; }
|
|
88
|
+
project-list, workspace-list { flex: 0 0 auto; max-height: 26%; min-height: 0; overflow: hidden; border-bottom: 1px solid var(--pi-border-muted); }
|
|
89
|
+
session-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
90
|
+
main { grid-column: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
|
|
91
|
+
.context-bar { position: relative; flex: 0 0 auto; min-width: 0; display: none; align-items: center; gap: 0; padding: 6px 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
92
|
+
.context-bar::before, .context-bar::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
93
|
+
.context-bar::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
94
|
+
.context-bar::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
95
|
+
.context-bar.can-scroll-left::before, .context-bar.can-scroll-right::after { opacity: 1; }
|
|
96
|
+
.context-bar-label { display: none; }
|
|
97
|
+
.context-items { flex: 1 1 auto; min-width: 0; display: flex; align-items: stretch; gap: 5px; margin: 0; padding: 0 8px; list-style: none; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-padding-inline: 8px; scrollbar-width: thin; }
|
|
98
|
+
.context-bar.has-context-actions .context-items { padding-right: 52px; scroll-padding-inline: 8px 52px; }
|
|
99
|
+
.context-item { flex: 0 0 auto; min-width: 0; display: flex; }
|
|
100
|
+
.context-actions { position: absolute; top: 6px; right: 0; bottom: 6px; z-index: 3; display: flex; align-items: center; padding: 0 8px 0 0; pointer-events: none; }
|
|
101
|
+
.context-actions::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; z-index: 0; width: 26px; background: var(--pi-bg); pointer-events: none; }
|
|
102
|
+
.app-refresh { position: relative; z-index: 1; display: flex; align-items: center; pointer-events: auto; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
|
|
103
|
+
.app-refresh, .app-refresh * { -webkit-user-select: none; user-select: none; }
|
|
104
|
+
.app-refresh-button { box-sizing: border-box; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 999px; padding: 0; line-height: 1; touch-action: manipulation; -webkit-touch-callout: none; }
|
|
105
|
+
.app-refresh-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
106
|
+
.app-refresh-button.refreshing .app-refresh-icon { animation: app-refresh-spin .8s linear infinite; }
|
|
107
|
+
.app-refresh-menu { position: fixed; z-index: 10000; box-sizing: border-box; min-width: min(170px, 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; }
|
|
108
|
+
.app-refresh-menu button { display: block; width: 100%; border: 0; background: transparent; color: var(--pi-text); text-align: left; white-space: normal; overflow-wrap: anywhere; }
|
|
109
|
+
.app-refresh-menu button:hover, .app-refresh-menu button:focus { background: var(--pi-selection-bg); }
|
|
110
|
+
.context-chip { flex: 0 0 auto; min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text); padding: 4px 8px; font: inherit; text-align: left; }
|
|
111
|
+
.context-chip:hover { background: var(--pi-surface-hover); }
|
|
112
|
+
.context-chip:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; }
|
|
113
|
+
.context-chip.empty { border-style: dashed; color: var(--pi-muted); }
|
|
114
|
+
.context-kind { display: none; }
|
|
115
|
+
.context-value { min-width: 0; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
116
|
+
.mobile-tabs-frame { position: relative; display: none; flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); background: var(--pi-bg); }
|
|
117
|
+
.mobile-tabs-frame::before, .mobile-tabs-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 20px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
118
|
+
.mobile-tabs-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
119
|
+
.mobile-tabs-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
120
|
+
.mobile-tabs-frame.can-scroll-left::before, .mobile-tabs-frame.can-scroll-right::after { opacity: 1; }
|
|
121
|
+
.mobile-tabs { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
122
|
+
.mobile-tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
123
|
+
.mobile-navigation-tab, .mobile-navigation-panel { display: none; }
|
|
124
|
+
.mobile-tabs button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
125
|
+
.tab-badge { display: inline-block; min-width: 14px; margin-left: 4px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
126
|
+
.navigation-panel-edge, .workspace-panel-edge { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: visible; background: var(--pi-border-muted); z-index: 2; }
|
|
127
|
+
.navigation-panel-edge { grid-column: 2; }
|
|
128
|
+
.workspace-panel-edge { grid-column: 4; }
|
|
129
|
+
.navigation-panel-edge-button, .workspace-panel-edge-button { position: relative; z-index: 1; box-sizing: border-box; display: grid; place-items: center; width: 18px; height: 48px; padding: 0; border: 1px solid var(--pi-border-muted); border-radius: 999px; background: var(--pi-bg); color: var(--pi-muted); opacity: .75; cursor: pointer; }
|
|
130
|
+
.navigation-panel-edge-button:hover, .navigation-panel-edge-button:focus-visible, .workspace-panel-edge-button:hover, .workspace-panel-edge-button:focus-visible { color: var(--pi-text); background: var(--pi-surface-hover); opacity: 1; }
|
|
131
|
+
.shell.navigation-panel-collapsed .navigation-panel-edge-button { transform: translateX(calc(50% - .5px)); }
|
|
132
|
+
.shell.workspace-panel-collapsed .workspace-panel-edge-button { transform: translateX(calc(-50% + .5px)); }
|
|
133
|
+
.navigation-panel-edge-icon, .workspace-panel-edge-icon { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
|
|
134
|
+
workspace-panel { grid-column: 5; min-width: 0; min-height: 0; overflow: hidden; }
|
|
135
|
+
@media (min-width: 1181px) {
|
|
136
|
+
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
137
|
+
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
138
|
+
.shell.workspace-panel-collapsed { --workspace-panel-width: 0px; }
|
|
139
|
+
.shell.workspace-panel-collapsed > workspace-panel { display: none; }
|
|
140
|
+
}
|
|
141
|
+
@media (max-width: 1180px) {
|
|
142
|
+
.shell { grid-template-columns: var(--navigation-panel-width) 1px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
|
|
143
|
+
.shell.navigation-panel-collapsed { --navigation-panel-width: 0px; }
|
|
144
|
+
.shell.navigation-panel-collapsed > aside { display: none; }
|
|
145
|
+
aside { grid-row: 1 / 3; }
|
|
146
|
+
.navigation-panel-edge { grid-row: 1 / 3; }
|
|
147
|
+
main { grid-column: 3; grid-row: 1 / 3; }
|
|
148
|
+
.mobile-tabs-frame { display: flex; }
|
|
149
|
+
.shell.workspace-view main { grid-row: 1; min-height: auto; }
|
|
150
|
+
.shell.workspace-view > workspace-panel { grid-column: 3; grid-row: 2; display: flex; border-left: 0; }
|
|
151
|
+
.shell:not(.workspace-view) > workspace-panel { display: none; }
|
|
152
|
+
.workspace-panel-edge { display: none; }
|
|
153
|
+
main.workspace-view chat-view, main.workspace-view prompt-editor, main.workspace-view status-bar,
|
|
154
|
+
main.workspace-view .empty { display: none; }
|
|
155
|
+
main.workspace-view { overflow: hidden; }
|
|
156
|
+
}
|
|
157
|
+
@media (max-width: 760px) {
|
|
158
|
+
.shell { grid-template-columns: minmax(0, 1fr); }
|
|
159
|
+
aside, .navigation-panel-edge { display: none; }
|
|
160
|
+
main, .shell.workspace-view > workspace-panel { grid-column: 1; }
|
|
161
|
+
.context-bar { display: flex; }
|
|
162
|
+
.mobile-navigation-tab { display: block; }
|
|
163
|
+
main.navigation-view chat-view, main.navigation-view prompt-editor, main.navigation-view status-bar,
|
|
164
|
+
main.navigation-view .empty { display: none; }
|
|
165
|
+
main.navigation-view .mobile-navigation-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
|
|
166
|
+
main.navigation-view .mobile-navigation-panel project-list,
|
|
167
|
+
main.navigation-view .mobile-navigation-panel workspace-list,
|
|
168
|
+
main.navigation-view .mobile-navigation-panel session-list { flex: 1 1 auto; max-height: none; min-height: 0; overflow: hidden; }
|
|
169
|
+
main.navigation-view .mobile-navigation-panel project-list[collapsed],
|
|
170
|
+
main.navigation-view .mobile-navigation-panel workspace-list[collapsed],
|
|
171
|
+
main.navigation-view .mobile-navigation-panel session-list[collapsed] { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
172
|
+
}
|
|
173
|
+
status-bar { flex: 0 0 auto; }
|
|
174
|
+
chat-view { flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
175
|
+
prompt-editor, chat-composer { flex: 0 0 auto; }
|
|
176
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
177
|
+
.empty { margin: auto; color: var(--pi-muted); }
|
|
178
|
+
.error { padding: 10px 16px; border-bottom: 1px solid var(--pi-border); color: var(--pi-danger); }
|
|
179
|
+
@keyframes app-refresh-spin { to { transform: rotate(360deg); } }
|
|
180
|
+
`,hd=V`
|
|
181
|
+
:host { display: flex; flex-direction: column; min-height: 0; color: var(--pi-text); background: var(--pi-bg); font: 13px system-ui, sans-serif; }
|
|
182
|
+
header { flex: 0 0 auto; min-width: 0; border-bottom: 1px solid var(--pi-border); }
|
|
183
|
+
.workspace-header-scroll-frame { position: relative; min-width: 0; background: var(--pi-bg); }
|
|
184
|
+
.workspace-header-scroll-frame::before, .workspace-header-scroll-frame::after { content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; width: 18px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
|
|
185
|
+
.workspace-header-scroll-frame::before { left: 0; background: linear-gradient(90deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
186
|
+
.workspace-header-scroll-frame::after { right: 0; background: linear-gradient(270deg, color-mix(in srgb, var(--pi-shadow-strong) 55%, transparent) 0%, transparent 100%); }
|
|
187
|
+
.workspace-header-scroll-frame.can-scroll-left::before, .workspace-header-scroll-frame.can-scroll-right::after { opacity: 1; }
|
|
188
|
+
.workspace-header-strip { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-width: 0; padding: 8px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; }
|
|
189
|
+
.tabs { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
|
|
190
|
+
.tabs button { flex: 0 0 auto; white-space: nowrap; }
|
|
191
|
+
button { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--pi-border); border-radius: 7px; background: var(--pi-surface); color: var(--pi-text); padding: 5px 7px; cursor: pointer; }
|
|
192
|
+
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
193
|
+
.tab-badge { display: inline-block; min-width: 14px; border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 0 5px; font-size: 11px; line-height: 16px; text-align: center; }
|
|
194
|
+
.panel-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
|
|
195
|
+
.empty-state { box-sizing: border-box; width: min(100%, 380px); margin: auto; padding: 24px; display: grid; gap: 8px; color: var(--pi-muted); text-align: center; }
|
|
196
|
+
.empty-state h2 { margin: 0; color: var(--pi-text); font-size: 15px; line-height: 1.3; }
|
|
197
|
+
.empty-state p { margin: 0; line-height: 1.45; }
|
|
198
|
+
small, .muted { color: var(--pi-muted); }
|
|
199
|
+
header small { flex: 0 0 auto; min-width: max-content; overflow: visible; text-overflow: clip; white-space: nowrap; }
|
|
200
|
+
header .workspace-label { width: max-content; max-width: none; overflow: visible; }
|
|
201
|
+
header .workspace-label-base, header .workspace-label-item, header .workspace-label-render { overflow: visible; text-overflow: clip; }
|
|
202
|
+
@media (max-width: 1180px) { .tabs { display: none; } }
|
|
203
|
+
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
204
|
+
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
205
|
+
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
206
|
+
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
207
|
+
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
208
|
+
.toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
209
|
+
.toolbar button { margin-left: auto; }
|
|
210
|
+
.stale { border: 1px solid var(--pi-warning-border); border-radius: 999px; color: var(--pi-warning); padding: 1px 6px; font-size: 12px; }
|
|
211
|
+
.split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-rows: minmax(160px, 34%) minmax(0, 1fr); }
|
|
212
|
+
.list { min-height: 0; overflow: auto; border-bottom: 1px solid var(--pi-border); padding: 6px; }
|
|
213
|
+
.row { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px; width: 100%; border: 0; border-radius: 5px; background: transparent; text-align: left; padding: 4px 6px 4px calc(6px + var(--depth, 0) * 14px); }
|
|
214
|
+
.row:hover, .row.selected { background: var(--pi-selection-bg); }
|
|
215
|
+
.row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
216
|
+
.summary { margin: 4px 6px 8px; color: var(--pi-muted); }
|
|
217
|
+
.viewer { min-height: 0; overflow: auto; display: flex; flex-direction: column; }
|
|
218
|
+
.diffs { flex: 1 1 auto; min-height: 0; overflow: auto; display: grid; grid-template-rows: minmax(120px, 1fr) minmax(120px, 1fr); }
|
|
219
|
+
.diffs.single { grid-template-rows: minmax(0, 1fr); }
|
|
220
|
+
.diff-section { min-height: 0; display: flex; flex-direction: column; border-bottom: 1px solid var(--pi-border); }
|
|
221
|
+
.diff-section:last-child { border-bottom: 0; }
|
|
222
|
+
.viewer-header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 8px; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); }
|
|
223
|
+
.viewer-header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
224
|
+
code-viewer { flex: 1 1 auto; min-height: 0; }
|
|
225
|
+
.image-preview { flex: 1 1 auto; min-height: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 16px; }
|
|
226
|
+
.image-preview img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid var(--pi-border-muted); border-radius: 8px; background-color: var(--pi-surface); background-image: linear-gradient(45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(-45deg, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%), linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--pi-border-muted) 45%, transparent) 75%); background-position: 0 0, 0 8px, 8px -8px, -8px 0; background-size: 16px 16px; box-shadow: 0 8px 24px var(--pi-shadow-soft); }
|
|
227
|
+
pre { margin: 0; padding: 10px; overflow: auto; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
228
|
+
p { margin: 10px; }
|
|
229
|
+
`,Ci=V`
|
|
230
|
+
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
231
|
+
:host([collapsed]) { flex: 0 0 auto; min-height: auto; overflow: hidden; }
|
|
232
|
+
section { box-sizing: border-box; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
|
|
233
|
+
h2 { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
234
|
+
.list-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
235
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
236
|
+
section > button { display: block; width: 100%; text-align: left; margin: 6px 0; }
|
|
237
|
+
.subheading { margin-top: 14px; }
|
|
238
|
+
.section-toggle { display: flex; flex: 1 1 auto; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; width: 100%; border: 0; background: transparent; color: inherit; padding: 0; font: inherit; text-align: left; text-transform: inherit; }
|
|
239
|
+
.section-toggle span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
240
|
+
.section-title { display: grid; gap: 2px; min-width: 0; }
|
|
241
|
+
.section-toggle .section-selected { display: block; color: var(--pi-text); font-size: 12px; font-weight: 600; line-height: 1.25; text-transform: none; }
|
|
242
|
+
.section-toggle .section-count { flex: 0 0 auto; display: inline; color: var(--pi-muted); font-size: inherit; }
|
|
243
|
+
.section-toggle small { display: inline; color: inherit; font-size: inherit; }
|
|
244
|
+
.action-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 6px 0; cursor: pointer; }
|
|
245
|
+
.action-row:focus-visible { outline: 2px solid var(--pi-accent); outline-offset: 2px; border-radius: 8px; }
|
|
246
|
+
.action-row.selected .action-main, .action-row.selected .action-menu-toggle { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
247
|
+
.action-row.archived .action-main { color: var(--pi-muted); }
|
|
248
|
+
.action-main { box-sizing: border-box; min-width: 0; width: 100%; border: 1px solid var(--pi-border); border-top-right-radius: 0; border-bottom-right-radius: 0; border-top-left-radius: 8px; border-bottom-left-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px 7px calc(9px + var(--depth, 0) * 16px); text-align: left; }
|
|
249
|
+
.action-name { display: -webkit-box; max-height: 2.5em; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
|
250
|
+
.action-row:not(.selected):hover .action-main { background: var(--pi-surface-hover); }
|
|
251
|
+
.workspace-row .action-main { border-radius: 8px 0 0 8px; }
|
|
252
|
+
.workspace-primary { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
|
|
253
|
+
.workspace-primary .activity-indicator { flex: 0 0 auto; margin-right: 0; }
|
|
254
|
+
.workspace-primary-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
255
|
+
.workspace-status { flex: 0 0 auto; color: var(--pi-warning); font-size: 12px; }
|
|
256
|
+
.workspace-secondary { margin-top: 3px; }
|
|
257
|
+
.workspace-menu-panel { width: max-content; min-width: min(120px, calc(100vw - 16px)); padding: 8px; }
|
|
258
|
+
.workspace-menu-actions { margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--pi-border-muted); }
|
|
259
|
+
.workspace-menu-actions button.danger { color: var(--pi-danger); }
|
|
260
|
+
.workspace-menu-actions button.danger:hover, .workspace-menu-actions button.danger:focus { background: color-mix(in srgb, var(--pi-danger) 14%, transparent); }
|
|
261
|
+
.workspace-menu-details { display: grid; gap: 6px; margin: 0; }
|
|
262
|
+
.workspace-detail-row { display: grid; grid-template-columns: minmax(58px, max-content) minmax(0, 1fr); gap: 8px; align-items: baseline; }
|
|
263
|
+
.workspace-detail-row dt { color: var(--pi-muted); font-size: 12px; white-space: normal; }
|
|
264
|
+
.workspace-detail-row dd { min-width: 0; margin: 0; overflow-wrap: anywhere; white-space: normal; }
|
|
265
|
+
.tree-marker { color: var(--pi-dim); margin-right: 5px; }
|
|
266
|
+
.badge { display: inline-block; margin-left: 5px; border: 1px solid var(--pi-border); border-radius: 999px; color: var(--pi-muted); padding: 0 5px; font-size: 11px; font-weight: 400; }
|
|
267
|
+
.activity-indicator { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--pi-success); animation: pulse 1s ease-in-out infinite; vertical-align: 1px; }
|
|
268
|
+
.activity-indicator.session { border-radius: 50%; background: var(--pi-success); }
|
|
269
|
+
.activity-indicator.terminal { border-radius: 2px; background: var(--pi-accent); }
|
|
270
|
+
.action-menu { position: relative; align-self: stretch; }
|
|
271
|
+
.action-menu-toggle { display: grid; place-items: center; height: 100%; min-width: 32px; padding: 0; color: var(--pi-muted); border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
|
|
272
|
+
.action-menu-toggle:hover { color: var(--pi-text); background: var(--pi-surface-hover); }
|
|
273
|
+
.action-menu-panel { position: fixed; z-index: 50; box-sizing: border-box; min-width: min(120px, calc(100vw - 16px)); overflow: auto; padding: 4px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 8px 24px var(--pi-shadow); overflow-wrap: anywhere; }
|
|
274
|
+
.action-menu-panel button { display: block; width: 100%; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 0; background: transparent; color: var(--pi-text); }
|
|
275
|
+
.action-menu-panel button:hover { background: var(--pi-selection-bg); }
|
|
276
|
+
button.selected { border-color: var(--pi-accent); background: var(--pi-selection-bg); }
|
|
277
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
278
|
+
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
279
|
+
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
280
|
+
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
281
|
+
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
282
|
+
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
283
|
+
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
284
|
+
.workspace-detail-row .workspace-label { overflow: visible; white-space: normal; flex-wrap: wrap; }
|
|
285
|
+
.workspace-detail-row .workspace-label-base, .workspace-detail-row .workspace-label-item, .workspace-detail-row .workspace-label-render { overflow: visible; text-overflow: clip; overflow-wrap: anywhere; white-space: normal; }
|
|
286
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
287
|
+
`,ud=V`
|
|
288
|
+
:host { display: flex; flex-direction: column; min-height: 0; overflow: hidden; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
289
|
+
.chat-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
|
|
290
|
+
.chat { height: 100%; min-height: 0; overflow: auto; overflow-anchor: none; padding: 26px 16px 64px; box-sizing: border-box; }
|
|
291
|
+
.scroll-marker { display: block; height: 0; overflow: hidden; pointer-events: none; }
|
|
292
|
+
.activity-dock { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 8px; min-width: 0; box-sizing: border-box; border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-bg-overlay); color: var(--pi-muted); padding: 8px 12px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 28px var(--pi-shadow); backdrop-filter: blur(6px); }
|
|
293
|
+
.activity-dock.active { border-color: var(--pi-success-border); color: var(--pi-success); background: var(--pi-success-bg-overlay); }
|
|
294
|
+
.activity-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
295
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
296
|
+
.activity-dock.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
297
|
+
.msg { max-width: 100%; min-width: 0; box-sizing: border-box; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); overflow: visible; }
|
|
298
|
+
.msg.user { border-color: var(--pi-accent-border); background: var(--pi-selection-bg); }
|
|
299
|
+
.msg.tool { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); color: var(--pi-warning); }
|
|
300
|
+
.msg.tool-execution-shell { padding: 0; border: 0; background: transparent; color: var(--pi-text); }
|
|
301
|
+
.msg.system { color: var(--pi-danger); }
|
|
302
|
+
.msg.bash { border-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
303
|
+
.msg.skill { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
304
|
+
.msg.event-group { padding: 0; border-color: var(--pi-border); background: var(--pi-bg); color: var(--pi-muted); }
|
|
305
|
+
.msg.event-group.live { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
306
|
+
.msg.event-group > summary { position: sticky; top: -26px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px 9px 0 0; border-bottom: 1px solid var(--pi-border-muted); background: var(--pi-bg); color: var(--pi-muted); }
|
|
307
|
+
.msg.event-group.live > summary { border-bottom-color: var(--pi-success-border); background: var(--pi-success-bg); color: var(--pi-success); }
|
|
308
|
+
.msg.event-group > summary .label { margin: 0; }
|
|
309
|
+
.group-body { padding: 0 12px 12px; }
|
|
310
|
+
.group-msg { max-width: 100%; min-width: 0; box-sizing: border-box; padding: 10px 0; border-top: 1px solid var(--pi-border-muted); color: var(--pi-text); overflow: visible; }
|
|
311
|
+
.group-msg.tool { color: var(--pi-warning); }
|
|
312
|
+
.group-msg.tool-execution-shell { color: var(--pi-text); }
|
|
313
|
+
.group-msg.system { color: var(--pi-danger); }
|
|
314
|
+
.group-msg.bash { color: var(--pi-success); }
|
|
315
|
+
.history-boundary { position: relative; z-index: 5; display: grid; gap: 3px; justify-items: center; margin: 0 0 14px; color: var(--pi-muted); font-size: 12px; text-align: center; }
|
|
316
|
+
.history-load-button { border: 1px solid var(--pi-border); border-radius: 999px; background: var(--pi-surface); color: var(--pi-text-secondary); padding: 5px 12px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
317
|
+
.history-load-button:hover, .history-load-button:focus { border-color: var(--pi-accent); color: var(--pi-text-bright); }
|
|
318
|
+
.history-load-button:disabled { cursor: default; opacity: .55; }
|
|
319
|
+
.queued-messages { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 8px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-warning-border); border-radius: 10px; background: var(--pi-warning-surface); color: var(--pi-text); overflow: hidden; }
|
|
320
|
+
.queued-header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
|
|
321
|
+
.queued-header strong { color: var(--pi-warning); }
|
|
322
|
+
.queued-header small { color: var(--pi-muted); }
|
|
323
|
+
.queued-message { display: grid; gap: 4px; padding-top: 8px; border-top: 1px solid var(--pi-border); }
|
|
324
|
+
.queued-message:first-of-type { padding-top: 0; border-top: 0; }
|
|
325
|
+
.queued-kind { color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
326
|
+
.session-activity { max-width: 100%; min-width: 0; box-sizing: border-box; display: grid; gap: 4px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--pi-border); border-radius: 10px; background: var(--pi-surface); color: var(--pi-text); overflow: hidden; }
|
|
327
|
+
.session-activity.compacting { border-color: var(--pi-purple-border); background: var(--pi-purple-surface); }
|
|
328
|
+
.session-activity.receiving { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
329
|
+
.session-activity strong { color: var(--pi-purple); }
|
|
330
|
+
.session-activity.receiving strong { color: var(--pi-success); }
|
|
331
|
+
.session-activity span, .session-activity small { color: var(--pi-muted); }
|
|
332
|
+
.history-boundary small { color: var(--pi-dim); }
|
|
333
|
+
.msg-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; margin-bottom: 8px; }
|
|
334
|
+
.msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -12px -12px 8px; padding: 7px 10px 6px; border-radius: 9px 9px 0 0; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-surface); box-shadow: 0 8px 18px var(--pi-shadow-soft); }
|
|
335
|
+
.msg.user > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-accent-border) 35%, transparent); background: var(--pi-selection-bg); }
|
|
336
|
+
.msg.tool > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-warning-border) 35%, transparent); background: var(--pi-warning-surface); }
|
|
337
|
+
.msg.bash > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-success) 35%, transparent); background: var(--pi-success-bg); }
|
|
338
|
+
.msg.skill > .msg-header { border-bottom-color: color-mix(in srgb, var(--pi-purple-border) 35%, transparent); background: var(--pi-purple-surface); }
|
|
339
|
+
.group-msg > .msg-header { position: sticky; top: -26px; z-index: 4; margin: -10px 0 8px; padding: 7px 0 6px; border-bottom: 1px solid color-mix(in srgb, var(--pi-border-muted) 35%, transparent); background: var(--pi-bg); }
|
|
340
|
+
.msg-header-trailing { min-width: 0; display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
|
|
341
|
+
.msg-actions { display: inline-flex; gap: 6px; opacity: 0; transition: opacity .12s ease; }
|
|
342
|
+
.msg-action { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
343
|
+
.msg-action:hover, .msg-action:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
344
|
+
.msg:hover > .msg-header .msg-actions, .msg:focus-within > .msg-header .msg-actions, .group-msg:hover > .msg-header .msg-actions, .group-msg:focus-within > .msg-header .msg-actions { opacity: 1; }
|
|
345
|
+
.label { display: block; color: var(--pi-muted); font-size: 12px; text-transform: uppercase; }
|
|
346
|
+
.msg-header .label { margin: 0; }
|
|
347
|
+
.msg-meta { min-width: 0; opacity: .28; border: 0; background: transparent; color: var(--pi-dim); padding: 0; font: 11px system-ui, sans-serif; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .12s ease, max-width .12s ease; cursor: pointer; user-select: text; -webkit-user-select: text; }
|
|
348
|
+
.msg:hover > .msg-header .msg-meta, .msg:focus-within > .msg-header .msg-meta, .group-msg:hover > .msg-header .msg-meta, .group-msg:focus-within > .msg-header .msg-meta, .msg-meta:focus, .msg-meta.expanded { opacity: 1; }
|
|
349
|
+
.msg-meta:focus { outline: 1px solid var(--pi-border); outline-offset: 3px; border-radius: 4px; }
|
|
350
|
+
@media (hover: none) {
|
|
351
|
+
.msg-actions { opacity: 1; }
|
|
352
|
+
.msg-meta { opacity: .75; max-width: 26px; }
|
|
353
|
+
.msg-meta::before { content: "ⓘ"; font-size: 13px; }
|
|
354
|
+
.msg-meta:focus, .msg-meta.expanded { opacity: 1; max-width: 75%; }
|
|
355
|
+
.msg-meta:focus::before, .msg-meta.expanded::before { content: ""; }
|
|
356
|
+
}
|
|
357
|
+
formatted-text.part { display: block; }
|
|
358
|
+
.part { max-width: 100%; min-width: 0; box-sizing: border-box; overflow: visible; }
|
|
359
|
+
.part + .part { margin-top: 10px; }
|
|
360
|
+
.tool-line { color: var(--pi-warning); }
|
|
361
|
+
.summary { color: var(--pi-muted); margin-left: 6px; }
|
|
362
|
+
.part:is(details) { border-top: 1px solid var(--pi-border); padding-top: 8px; }
|
|
363
|
+
.part > formatted-text { display: block; max-width: 100%; min-width: 0; overflow: visible; }
|
|
364
|
+
.skill-invocation, .skill-read { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); padding: 8px 10px; }
|
|
365
|
+
.skill-invocation > summary, .skill-read > strong { color: var(--pi-purple); }
|
|
366
|
+
.skill-invocation > small, .skill-read > small { display: block; margin: 6px 0 0; color: var(--pi-muted); }
|
|
367
|
+
summary { cursor: pointer; color: var(--pi-muted); }
|
|
368
|
+
pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
|
|
369
|
+
.shell-output { color: var(--pi-text); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
370
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
371
|
+
`,fd=V`
|
|
372
|
+
:host { display: block; }
|
|
373
|
+
.formatted { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
|
|
374
|
+
p, ul, ol, pre, blockquote, table, .code-block-wrapper { margin: 0 0 10px; }
|
|
375
|
+
:is(p, ul, ol, pre, blockquote, table, .code-block-wrapper):last-child { margin-bottom: 0; }
|
|
376
|
+
ul, ol { padding-left: 22px; }
|
|
377
|
+
li + li { margin-top: 3px; }
|
|
378
|
+
code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-bg); padding: 1px 4px; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
379
|
+
.code-block-wrapper { position: relative; }
|
|
380
|
+
.code-block-wrapper pre { margin: 0; padding-right: 40px; }
|
|
381
|
+
pre { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); padding: 10px; overflow-x: auto; overflow-y: hidden; }
|
|
382
|
+
pre code { border: 0; padding: 0; background: transparent; }
|
|
383
|
+
.code-copy-button { position: absolute; top: 6px; right: 6px; z-index: 1; display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 0; font: 14px system-ui, sans-serif; line-height: 1; cursor: pointer; }
|
|
384
|
+
.code-copy-button:hover, .code-copy-button:focus { color: var(--pi-text); border-color: var(--pi-accent); }
|
|
385
|
+
blockquote { border-left: 3px solid var(--pi-border); padding-left: 10px; color: var(--pi-muted); }
|
|
386
|
+
a { color: var(--pi-accent); }
|
|
387
|
+
h1, h2, h3, h4 { margin: 14px 0 8px; line-height: 1.2; }
|
|
388
|
+
h1:first-child, h2:first-child, h3:first-child, h4:first-child { margin-top: 0; }
|
|
389
|
+
h1 { font-size: 20px; }
|
|
390
|
+
h2 { font-size: 17px; }
|
|
391
|
+
h3 { font-size: 15px; }
|
|
392
|
+
h4 { font-size: 14px; }
|
|
393
|
+
table { border-collapse: collapse; display: block; overflow-x: auto; overflow-y: hidden; }
|
|
394
|
+
th, td { border: 1px solid var(--pi-border); padding: 4px 8px; }
|
|
395
|
+
th { background: var(--pi-surface); }
|
|
396
|
+
`,md=V`
|
|
397
|
+
:host { display: block; color: var(--pi-muted); font: 12px system-ui, sans-serif; }
|
|
398
|
+
.bar { display: flex; gap: 12px; align-items: center; min-width: 0; padding: 7px 12px; border-top: 1px solid var(--pi-border); background: var(--pi-bg); white-space: nowrap; overflow: hidden; }
|
|
399
|
+
span { overflow: hidden; text-overflow: ellipsis; }
|
|
400
|
+
.workspace-label { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
|
|
401
|
+
.workspace-label-base, .workspace-label-item, .workspace-label-render { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
402
|
+
.workspace-label-item, .workspace-label-render, .workspace-label-separator { color: var(--pi-muted); }
|
|
403
|
+
.workspace-label-link { color: var(--pi-accent); text-decoration: none; }
|
|
404
|
+
.workspace-label-link:hover, .workspace-label-link:focus { text-decoration: underline; }
|
|
405
|
+
.bar > span:first-child { flex: 1 1 auto; min-width: 80px; }
|
|
406
|
+
.activity { display: inline-flex; align-items: center; gap: 6px; color: var(--pi-muted); }
|
|
407
|
+
.activity.active { color: var(--pi-success); }
|
|
408
|
+
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
|
|
409
|
+
.activity.active .dot { animation: pulse 1s ease-in-out infinite; opacity: 1; }
|
|
410
|
+
.muted { color: var(--pi-dim); }
|
|
411
|
+
@keyframes pulse { 0%, 100% { transform: scale(.75); opacity: .55; } 50% { transform: scale(1.2); opacity: 1; } }
|
|
412
|
+
`,gd=V`
|
|
413
|
+
:host { display: block; }
|
|
414
|
+
.menu { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 10; max-height: 260px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); box-shadow: 0 10px 30px var(--pi-shadow); }
|
|
415
|
+
button { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 4px 10px; width: 100%; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; cursor: pointer; }
|
|
416
|
+
button:last-child { border-bottom: 0; }
|
|
417
|
+
button.selected, button:hover { background: var(--pi-selection-bg); }
|
|
418
|
+
span { color: var(--pi-muted); font-size: 12px; }
|
|
419
|
+
small { grid-column: 1 / -1; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
420
|
+
`,Or=V`
|
|
421
|
+
:host { position: fixed; inset: 0; z-index: 10; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
422
|
+
.backdrop { display: grid; place-items: center; width: 100%; height: 100%; background: var(--pi-overlay); }
|
|
423
|
+
section { width: min(720px, calc(100vw - 40px)); max-height: min(640px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
424
|
+
header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
425
|
+
.options { min-height: 0; overflow: auto; outline: none; }
|
|
426
|
+
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
427
|
+
header button { font-size: 20px; color: var(--pi-muted); }
|
|
428
|
+
input { margin: 10px 12px; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); font: 14px system-ui, sans-serif; padding: 8px 10px; outline: none; }
|
|
429
|
+
input:focus { border-color: var(--pi-accent); }
|
|
430
|
+
.options button { display: block; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
431
|
+
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
432
|
+
small { display: block; margin-top: 4px; color: var(--pi-muted); }
|
|
433
|
+
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
434
|
+
`,vd=V`
|
|
435
|
+
:host { position: fixed; inset: 0; z-index: 20; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
436
|
+
.backdrop { --palette-top: min(12dvh, 90px); --palette-bottom: max(20px, env(safe-area-inset-bottom)); display: grid; align-items: start; justify-items: center; width: 100%; height: 100dvh; background: var(--pi-overlay); padding: var(--palette-top) 20px var(--palette-bottom); box-sizing: border-box; overflow: hidden; }
|
|
437
|
+
section { width: min(720px, 100%); max-height: min(640px, calc(100dvh - var(--palette-top) - var(--palette-bottom))); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
438
|
+
header { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-bottom: 1px solid var(--pi-border); }
|
|
439
|
+
input { min-width: 0; border: 0; outline: none; background: transparent; color: var(--pi-text); font: 16px system-ui, sans-serif; padding: 8px; }
|
|
440
|
+
input::placeholder { color: var(--pi-dim); }
|
|
441
|
+
button { border: 0; background: transparent; color: var(--pi-text); cursor: pointer; }
|
|
442
|
+
header button { color: var(--pi-muted); font-size: 22px; padding: 2px 8px; }
|
|
443
|
+
.options { flex: 1 1 auto; min-height: 0; overflow: auto; }
|
|
444
|
+
.options button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; width: 100%; padding: 10px 12px; border-bottom: 1px solid var(--pi-border-muted); text-align: left; }
|
|
445
|
+
.options button.selected, .options button:hover { background: var(--pi-selection-bg); }
|
|
446
|
+
.main { min-width: 0; }
|
|
447
|
+
strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
448
|
+
small { display: block; color: var(--pi-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
449
|
+
.group { grid-column: 1 / -1; font-size: 12px; }
|
|
450
|
+
kbd { align-self: center; border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-muted); padding: 2px 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
|
|
451
|
+
.empty { padding: 24px; color: var(--pi-muted); text-align: center; }
|
|
452
|
+
`,bd=V`
|
|
453
|
+
:host { position: relative; z-index: 5; display: block; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
454
|
+
footer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px; border-top: 1px solid var(--pi-border); }
|
|
455
|
+
footer.shell-mode { border-top-color: var(--pi-success); background: var(--pi-success-bg); }
|
|
456
|
+
.editor-wrap { position: relative; min-width: 0; }
|
|
457
|
+
.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; white-space: nowrap; }
|
|
458
|
+
.compact-status { display: flex; min-width: 0; align-items: center; gap: 6px; color: var(--pi-muted); font-size: 12px; flex: 1 1 0; }
|
|
459
|
+
.compact-status > button { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
460
|
+
.select-model { max-width: min(42vw, 320px); }
|
|
461
|
+
.select-thinking { max-width: 110px; }
|
|
462
|
+
textarea, .markdown-editor .cm-editor { box-sizing: border-box; width: 100%; min-height: 54px; max-height: 220px; resize: none; overflow: hidden; border-radius: 8px; border: 1px solid var(--pi-border); background: var(--pi-bg); color: var(--pi-text); font: 16px/1.4 system-ui, sans-serif; }
|
|
463
|
+
textarea { overflow-y: auto; padding: 8px; }
|
|
464
|
+
.markdown-editor .cm-scroller { max-height: 220px; overflow-y: auto; font-family: system-ui, sans-serif; line-height: 1.4; }
|
|
465
|
+
.markdown-editor .cm-content { min-height: 38px; padding: 8px; caret-color: var(--pi-text); }
|
|
466
|
+
.markdown-editor .cm-line { padding: 0; }
|
|
467
|
+
.markdown-editor .cm-placeholder { color: var(--pi-dim); }
|
|
468
|
+
.markdown-editor .cm-focused { outline: none; }
|
|
469
|
+
.shell-mode textarea, .shell-mode .markdown-editor .cm-editor { border-color: var(--pi-success); box-shadow: 0 0 0 1px var(--pi-success-ring); }
|
|
470
|
+
.mode-hint { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); border: 1px solid var(--pi-success-border); border-radius: 999px; background: var(--pi-success-surface); color: var(--pi-success); padding: 2px 8px; font-size: 12px; pointer-events: none; }
|
|
471
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
472
|
+
button:disabled, textarea:disabled, .markdown-editor-disabled .cm-editor { opacity: .5; cursor: not-allowed; }
|
|
473
|
+
@media (max-width: 640px) {
|
|
474
|
+
footer { gap: 8px; padding: 8px; }
|
|
475
|
+
.actions { gap: 6px; }
|
|
476
|
+
.compact-status { flex: 1 1 220px; gap: 4px; }
|
|
477
|
+
.select-model { max-width: min(58vw, 260px); }
|
|
478
|
+
button { padding: 6px 8px; }
|
|
479
|
+
}
|
|
480
|
+
@media (max-width: 430px) {
|
|
481
|
+
.compact-status { flex-basis: 170px; font-size: 11px; }
|
|
482
|
+
.select-model { max-width: 48vw; }
|
|
483
|
+
.select-thinking { max-width: 70px; }
|
|
484
|
+
button { padding: 5px 7px; }
|
|
485
|
+
}
|
|
486
|
+
`;var wd=Object.defineProperty,yd=Object.getOwnPropertyDescriptor,J=(e,t,i,s)=>{for(var r=s>1?void 0:s?yd(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&wd(t,i,r),r};let q=class extends R{constructor(){super(...arguments),this.projects=[],this.activities={},this.workspacesByProjectId={},this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuProjectId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("projects")&&this.openMenuProjectId!==void 0&&!this.projects.some(t=>t.id===this.openMenuProjectId)&&(this.openMenuProjectId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuProjectId=void 0)}render(){return c`
|
|
487
|
+
<section>
|
|
488
|
+
<h2>${this.renderHeading()}</h2>
|
|
489
|
+
${this.collapsed?null:c`
|
|
490
|
+
<div class="list-body">
|
|
491
|
+
${this.projects.map(e=>c`
|
|
492
|
+
<div
|
|
493
|
+
class=${`action-row ${this.selected?.id===e.id?"selected":""}`}
|
|
494
|
+
tabindex="0"
|
|
495
|
+
title=${e.path}
|
|
496
|
+
@click=${t=>{Pi(t,()=>this.onSelect?.(e))}}
|
|
497
|
+
@keydown=${t=>{Ti(t,()=>this.onSelect?.(e))}}
|
|
498
|
+
>
|
|
499
|
+
<div class="action-main">
|
|
500
|
+
<span class="action-name">${e.name}</span><small>${this.renderActivity(e)}${e.path}</small>
|
|
501
|
+
</div>
|
|
502
|
+
<div class="action-menu">
|
|
503
|
+
<button class="action-menu-toggle" title="Project actions" aria-label=${`Actions for ${e.name}`} @click=${t=>{t.stopPropagation(),this.toggleMenu(e.id,t.currentTarget)}}>⋯</button>
|
|
504
|
+
${this.openMenuProjectId===e.id?c`
|
|
505
|
+
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
506
|
+
<button title="Close project" @click=${()=>{this.close(e)}}>Close</button>
|
|
507
|
+
</div>
|
|
508
|
+
`:null}
|
|
509
|
+
</div>
|
|
510
|
+
</div>
|
|
511
|
+
`)}
|
|
512
|
+
</div>
|
|
513
|
+
`}
|
|
514
|
+
</section>
|
|
515
|
+
`}renderHeading(){if(!this.collapsible)return"Projects";const e=this.selected?.name??"No project selected",t=this.selected?.path??e;return c`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Projects</span><small class="section-selected" title=${t}>${e}</small></span><small class="section-count">${this.projects.length}</small></button>`}renderActivity(e){const t=od(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=Mt(t),this.openMenuProjectId=e}close(e){this.openMenuProjectId=void 0,confirm(`Close ${e.name}?
|
|
516
|
+
|
|
517
|
+
This only removes it from PI WEB; it will not change the project folder.`)&&this.onClose?.(e)}};q.styles=Ci;J([h({attribute:!1})],q.prototype,"projects",2);J([h({attribute:!1})],q.prototype,"selected",2);J([h({attribute:!1})],q.prototype,"activities",2);J([h({attribute:!1})],q.prototype,"workspacesByProjectId",2);J([h({type:Boolean,reflect:!0})],q.prototype,"collapsible",2);J([h({type:Boolean,reflect:!0})],q.prototype,"collapsed",2);J([h({attribute:!1})],q.prototype,"onSelect",2);J([h({attribute:!1})],q.prototype,"onClose",2);J([h({attribute:!1})],q.prototype,"onToggleCollapsed",2);J([x()],q.prototype,"openMenuProjectId",2);J([x()],q.prototype,"menuStyle",2);q=J([F("project-list")],q);function Wr(e,t=[],i){return c`
|
|
518
|
+
<span class="workspace-label">
|
|
519
|
+
<span class="workspace-label-base" title=${i??e}>${e}</span>
|
|
520
|
+
${xd(t)}
|
|
521
|
+
</span>
|
|
522
|
+
`}function xd(e=[]){return e.map(t=>c`<span class="workspace-label-separator">·</span>${jr(t)}`)}function Cs(e=[]){return e.map((t,i)=>c`${i===0?null:c`<span class="workspace-label-separator">·</span>`}${jr(t)}`)}function jr(e){if(e.type==="render")return c`<span class="workspace-label-render">${e.render()}</span>`;if(e.type==="link"&&kd(e.href)){const t=e.target??"_blank",i=t==="_blank"?"noopener noreferrer":void 0;return c`<a class="workspace-label-item workspace-label-link" href=${e.href} title=${e.title??e.text} target=${t} rel=${i??void 0}>${e.text}</a>`}return c`<span class="workspace-label-item" title=${e.title??e.text}>${e.text}</span>`}function kd(e){const t=e.trim().toLowerCase();return t!==""&&!t.startsWith("javascript:")&&!t.startsWith("data:")}var Sd=Object.defineProperty,$d=Object.getOwnPropertyDescriptor,G=(e,t,i,s)=>{for(var r=s>1?void 0:s?$d(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Sd(t,i,r),r};let z=class extends R{constructor(){super(...arguments),this.workspaces=[],this.collapsible=!1,this.collapsed=!1,this.workspaceLabelItems=()=>[],this.activities={},this.deletingWorkspaceIds=[],this.menuStyle="",this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuWorkspaceId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("workspaces")&&this.openMenuWorkspaceId!==void 0&&!this.workspaces.some(t=>t.id===this.openMenuWorkspaceId)&&(this.openMenuWorkspaceId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuWorkspaceId=void 0),(e.has("selected")||e.has("workspaces")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}render(){return c`
|
|
523
|
+
<section>
|
|
524
|
+
<h2>${this.renderHeading()}</h2>
|
|
525
|
+
${this.collapsed?null:c`
|
|
526
|
+
<div class="list-body">
|
|
527
|
+
${this.workspaces.map(e=>{const t=Pd(e),i=this.workspaceLabelItems(e);return c`
|
|
528
|
+
<div
|
|
529
|
+
class=${`action-row workspace-row ${this.selected?.id===e.id?"selected":""}`}
|
|
530
|
+
tabindex="0"
|
|
531
|
+
title=${t}
|
|
532
|
+
@click=${s=>{Pi(s,()=>this.onSelect?.(e))}}
|
|
533
|
+
@keydown=${s=>{this.handleWorkspaceKeydown(s,e)}}
|
|
534
|
+
>
|
|
535
|
+
<div class="action-main">
|
|
536
|
+
${this.renderWorkspaceMain(t,i,e)}
|
|
537
|
+
</div>
|
|
538
|
+
${this.renderWorkspaceMenu(t,i,e)}
|
|
539
|
+
</div>
|
|
540
|
+
`})}
|
|
541
|
+
</div>
|
|
542
|
+
`}
|
|
543
|
+
</section>
|
|
544
|
+
`}renderHeading(){if(!this.collapsible)return"Workspaces";const e=this.selected===void 0?"No workspace selected":`${this.selected.label}${this.selected.isMain?" · main":""} · ${this.selected.path}`,t=this.selected?.path??e;return c`<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Workspaces</span><small class="section-selected" title=${t}>${e}</small></span><small class="section-count">${this.workspaces.length}</small></button>`}renderActivity(e){const t=rd(sd(e,this.activities));return $i(t,t==="terminal"?"Workspace terminal active":"Workspace active")}renderWorkspaceMain(e,t,i){return c`
|
|
545
|
+
<span class="workspace-primary">
|
|
546
|
+
${this.renderActivity(i)}
|
|
547
|
+
<span class="workspace-primary-label">${e}</span>
|
|
548
|
+
${this.isDeleting(i)?c`<span class="workspace-status">Deleting…</span>`:null}
|
|
549
|
+
</span>
|
|
550
|
+
${t.length===0?null:c`
|
|
551
|
+
<small class="workspace-secondary">
|
|
552
|
+
<span class="workspace-label">${Cs(t)}</span>
|
|
553
|
+
</small>
|
|
554
|
+
`}
|
|
555
|
+
`}renderWorkspaceMenu(e,t,i){const s=this.openMenuWorkspaceId===i.id,r=Cd(i.id);return c`
|
|
556
|
+
<div class="action-menu">
|
|
557
|
+
<button
|
|
558
|
+
class="action-menu-toggle"
|
|
559
|
+
title="Workspace actions and details"
|
|
560
|
+
aria-label=${`Actions and details for ${e}`}
|
|
561
|
+
aria-expanded=${String(s)}
|
|
562
|
+
aria-controls=${r}
|
|
563
|
+
@click=${o=>{o.stopPropagation(),this.toggleMenu(i.id,o.currentTarget)}}
|
|
564
|
+
>⋯</button>
|
|
565
|
+
${s?c`
|
|
566
|
+
<div class="action-menu-panel workspace-menu-panel" id=${r} style=${this.menuStyle} @click=${o=>{o.stopPropagation()}}>
|
|
567
|
+
${this.renderWorkspaceActions(i)}
|
|
568
|
+
${this.renderWorkspaceDetails(e,t,i)}
|
|
569
|
+
</div>
|
|
570
|
+
`:null}
|
|
571
|
+
</div>
|
|
572
|
+
`}renderWorkspaceActions(e){if(!Td(e))return;const t=this.isDeleting(e);return c`
|
|
573
|
+
<div class="workspace-menu-actions">
|
|
574
|
+
<button class="danger" title=${t?"Workspace deletion in progress":"Delete workspace"} ?disabled=${t} @click=${()=>{this.delete(e)}}>${t?"Deleting…":"Delete workspace"}</button>
|
|
575
|
+
</div>
|
|
576
|
+
`}renderWorkspaceDetails(e,t,i){return c`
|
|
577
|
+
<dl class="workspace-menu-details">
|
|
578
|
+
<div class="workspace-detail-row">
|
|
579
|
+
<dt>${i.branch===void 0?"Workspace":"Branch"}</dt>
|
|
580
|
+
<dd>${e}</dd>
|
|
581
|
+
</div>
|
|
582
|
+
<div class="workspace-detail-row">
|
|
583
|
+
<dt>Path</dt>
|
|
584
|
+
<dd title=${i.path}>${i.path}</dd>
|
|
585
|
+
</div>
|
|
586
|
+
${t.length===0?null:c`
|
|
587
|
+
<div class="workspace-detail-row">
|
|
588
|
+
<dt>Details</dt>
|
|
589
|
+
<dd><span class="workspace-label">${Cs(t)}</span></dd>
|
|
590
|
+
</div>
|
|
591
|
+
`}
|
|
592
|
+
</dl>
|
|
593
|
+
`}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=Mt(t),this.openMenuWorkspaceId=e}handleWorkspaceKeydown(e,t){if(e.key==="Escape"&&this.openMenuWorkspaceId===t.id){e.preventDefault(),e.stopPropagation(),this.openMenuWorkspaceId=void 0;return}Ti(e,()=>this.onSelect?.(t))}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}};z.styles=Ci;G([h({attribute:!1})],z.prototype,"workspaces",2);G([h({attribute:!1})],z.prototype,"selected",2);G([h({type:Boolean,reflect:!0})],z.prototype,"collapsible",2);G([h({type:Boolean,reflect:!0})],z.prototype,"collapsed",2);G([h({attribute:!1})],z.prototype,"workspaceLabelItems",2);G([h({attribute:!1})],z.prototype,"activities",2);G([h({attribute:!1})],z.prototype,"deletingWorkspaceIds",2);G([h({attribute:!1})],z.prototype,"onSelect",2);G([h({attribute:!1})],z.prototype,"onDelete",2);G([h({attribute:!1})],z.prototype,"onToggleCollapsed",2);G([x()],z.prototype,"openMenuWorkspaceId",2);G([x()],z.prototype,"menuStyle",2);z=G([F("workspace-list")],z);function Pd(e){return`${e.branch??e.label}${e.isMain?" · main":""}`}function Td(e){return e.isGitWorktree&&!e.isMain}function Cd(e){return`workspace-menu-${e.replace(/[^a-zA-Z0-9_-]/g,"-")}`}var Id=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,M=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ad(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Id(t,i,r),r};function qt(e){return e.name!==void 0&&e.name!==""?e.name:e.firstMessage!==""?e.firstMessage:e.id.slice(0,8)}let T=class extends R{constructor(){super(...arguments),this.sessions=[],this.statuses={},this.activities={},this.canStart=!1,this.collapsible=!1,this.collapsed=!1,this.menuStyle="",this.archivedExpanded=!1,this.onDocumentClick=e=>{e.composedPath().includes(this)||(this.openMenuSessionId=void 0)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.onDocumentClick)}disconnectedCallback(){document.removeEventListener("click",this.onDocumentClick),super.disconnectedCallback()}updated(e){e.has("sessions")&&this.openMenuSessionId!==void 0&&!this.sessions.some(i=>i.id===this.openMenuSessionId)&&(this.openMenuSessionId=void 0),e.has("collapsed")&&this.collapsed&&(this.openMenuSessionId=void 0),e.has("sessions")&&!this.sessions.some(i=>i.archived===!0)&&(this.archivedExpanded=!1);const t=e.get("selected");if(e.has("selected")&&this.selected?.archived===!0&&(t?.id!==this.selected.id||t.archived!==!0)&&!this.archivedExpanded){this.archivedExpanded=!0,this.updateComplete.then(()=>{this.scrollSelectedIntoView()});return}(e.has("selected")||e.has("sessions")||e.has("collapsed"))&&!this.collapsed&&this.scrollSelectedIntoView()}render(){const e=Md(this.sessions),t=new Set(e.map(r=>r.session.id)),i=Nr(this.sessions.filter(r=>r.archived===!0&&!t.has(r.id))),s=Rd(this.sessions);return c`
|
|
594
|
+
<section>
|
|
595
|
+
${this.renderHeading(e.length+i.length)}
|
|
596
|
+
${this.collapsed?null:c`
|
|
597
|
+
<div class="list-body">
|
|
598
|
+
${e.map(r=>this.renderSession(r,s.get(r.session.id)??0))}
|
|
599
|
+
${i.length>0?c`
|
|
600
|
+
<h2 class="subheading"><button class="section-toggle" aria-expanded=${String(this.archivedExpanded)} @click=${()=>{this.toggleArchived()}}><span>${this.archivedExpanded?"▾":"▸"} Archived</span><small>${i.length}</small></button></h2>
|
|
601
|
+
${this.archivedExpanded?i.map(r=>this.renderSession(r,s.get(r.session.id)??0)):null}
|
|
602
|
+
`:null}
|
|
603
|
+
</div>
|
|
604
|
+
`}
|
|
605
|
+
</section>
|
|
606
|
+
`}renderHeading(e){if(!this.collapsible)return c`<h2>Sessions <button ?disabled=${!this.canStart} @click=${()=>this.onStart?.()}>+</button></h2>`;const t=this.selected===void 0?"No session selected":qt(this.selected),i=this.selected?.path??t;return c`
|
|
607
|
+
<h2>
|
|
608
|
+
<button class="section-toggle" aria-expanded=${String(!this.collapsed)} @click=${()=>{this.onToggleCollapsed?.()}}><span class="section-title"><span class="section-name">${this.collapsed?"▸":"▾"} Sessions</span><small class="section-selected" title=${i}>${t}</small></span><small class="section-count">${e}</small></button>
|
|
609
|
+
<button ?disabled=${!this.canStart} @click=${s=>{s.stopPropagation(),this.onStart?.()}}>+</button>
|
|
610
|
+
</h2>
|
|
611
|
+
`}renderSession(e,t){const{session:i}=e,s=Math.min(e.depth,2);return c`
|
|
612
|
+
<div
|
|
613
|
+
class="action-row ${this.selected?.id===i.id?"selected":""} ${i.archived===!0?"archived":""}"
|
|
614
|
+
style=${`--depth:${String(s)}`}
|
|
615
|
+
tabindex="0"
|
|
616
|
+
title=${i.path}
|
|
617
|
+
@click=${r=>{Pi(r,()=>this.onSelect?.(i))}}
|
|
618
|
+
@keydown=${r=>{Ti(r,()=>this.onSelect?.(i))}}
|
|
619
|
+
>
|
|
620
|
+
<div class="action-main">
|
|
621
|
+
<span class="action-name">${e.depth>0?c`<span class="tree-marker">↳</span>`:null}${qt(i)}${e.depth>2?c` <span class="badge">depth ${e.depth}</span>`:null}${e.hasMissingParent?c` <span class="badge">parent unavailable</span>`:null}</span><small>${this.renderStatus(i)}${String(i.messageCount)} messages</small>
|
|
622
|
+
</div>
|
|
623
|
+
<div class="action-menu">
|
|
624
|
+
<button class="action-menu-toggle" title="Session actions" @click=${r=>{r.stopPropagation(),this.toggleMenu(i.id,r.currentTarget)}}>⋯</button>
|
|
625
|
+
${this.openMenuSessionId===i.id?c`
|
|
626
|
+
<div class="action-menu-panel" style=${this.menuStyle}>
|
|
627
|
+
${i.parentSessionPath!==void 0?c`<button title="Detach from parent" @click=${()=>{this.openMenuSessionId=void 0,this.onDetachParent?.(i)}}>Detach from parent</button>`:null}
|
|
628
|
+
${me(i)?c`<button title="Delete browser-cached new session" @click=${()=>{this.openMenuSessionId=void 0,this.onDelete?.(i)}}>Delete</button>`:i.archived===!0?c`<button title="Restore session" @click=${()=>{this.openMenuSessionId=void 0,this.onRestore?.(i)}}>Restore</button>`:c`
|
|
629
|
+
<button title="Archive session" @click=${()=>{this.openMenuSessionId=void 0,this.onArchive?.(i)}}>Archive</button>
|
|
630
|
+
${t>0?c`<button title="Archive this session and its descendants" @click=${()=>{this.openMenuSessionId=void 0,this.confirmArchiveWithDescendants(i,t)}}>Archive with descendants (${t})</button>`:null}
|
|
631
|
+
`}
|
|
632
|
+
</div>
|
|
633
|
+
`:null}
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
`}confirmArchiveWithDescendants(e,t){const i=t===1?"descendant session":"descendant sessions";confirm(`Archive “${qt(e)}” and ${String(t)} ${i}?`)&&this.onArchiveWithDescendants?.(e)}toggleMenu(e,t){if(this.openMenuSessionId===e){this.openMenuSessionId=void 0;return}this.menuStyle=Mt(t),this.openMenuSessionId=e}toggleArchived(){this.archivedExpanded=!this.archivedExpanded,this.archivedExpanded||(this.openMenuSessionId=void 0,this.onArchivedCollapsed?.())}scrollSelectedIntoView(){this.renderRoot.querySelector(".action-row.selected")?.scrollIntoView({block:"nearest"})}renderStatus(e){return me(e)?"new · ":e.archived===!0?"read-only · ":$i(At(this.statuses[e.id],this.activities[e.id])?"session":void 0,"Session active")??""}};T.styles=Ci;M([h({attribute:!1})],T.prototype,"sessions",2);M([h({attribute:!1})],T.prototype,"statuses",2);M([h({attribute:!1})],T.prototype,"activities",2);M([h({attribute:!1})],T.prototype,"selected",2);M([h({type:Boolean})],T.prototype,"canStart",2);M([h({type:Boolean,reflect:!0})],T.prototype,"collapsible",2);M([h({type:Boolean,reflect:!0})],T.prototype,"collapsed",2);M([h({attribute:!1})],T.prototype,"onSelect",2);M([h({attribute:!1})],T.prototype,"onStart",2);M([h({attribute:!1})],T.prototype,"onToggleCollapsed",2);M([h({attribute:!1})],T.prototype,"onArchivedCollapsed",2);M([x()],T.prototype,"openMenuSessionId",2);M([x()],T.prototype,"menuStyle",2);M([x()],T.prototype,"archivedExpanded",2);M([h({attribute:!1})],T.prototype,"onArchive",2);M([h({attribute:!1})],T.prototype,"onArchiveWithDescendants",2);M([h({attribute:!1})],T.prototype,"onRestore",2);M([h({attribute:!1})],T.prototype,"onDelete",2);M([h({attribute:!1})],T.prototype,"onDetachParent",2);T=M([F("session-list")],T);function Rd(e){const t=new Map;for(const s of e){if(s.parentSessionPath===void 0)continue;const r=t.get(s.parentSessionPath)??[];r.push(s),t.set(s.parentSessionPath,r)}const i=(s,r)=>{if(r.has(s.path))return 0;const o=new Set(r);o.add(s.path);let n=0;for(const a of t.get(s.path)??[])o.has(a.path)||(a.archived!==!0&&(n+=1),n+=i(a,o));return n};return new Map(e.map(s=>[s.id,i(s,new Set)]))}function Md(e){const t=new Map(e.map(s=>[s.path,s])),i=new Set;for(const s of e){if(s.archived===!0)continue;i.add(s.id);let r=s.parentSessionPath;const o=new Set([s.path]);for(;r!==void 0&&!o.has(r);){o.add(r);const n=t.get(r);if(n===void 0)break;i.add(n.id),r=n.parentSessionPath}}return Nr(e.filter(s=>i.has(s.id)))}function Nr(e){const t=new Map(e.map(n=>[n.path,n])),i=new Map,s=[];for(const n of e){const a=n.parentSessionPath,l=a===void 0?void 0:t.get(a);if(l===void 0){s.push(n);continue}const d=i.get(l.path)??[];d.push(n),i.set(l.path,d)}const r=[],o=(n,a,l)=>{if(l.has(n.path))return;const d=n.parentSessionPath;r.push({session:n,depth:a,hasMissingParent:d!==void 0&&!t.has(d)});const u=new Set(l);u.add(n.path);for(const p of i.get(n.path)??[])o(p,a+1,u)};for(const n of s)o(n,0,new Set);return r}const Ii={CHILD:2,ELEMENT:6},Ai=e=>(...t)=>({_$litDirective$:e,values:t});let Ri=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}};const{I:Ed}=Wo,Is=e=>e,As=()=>document.createComment(""),Fe=(e,t,i)=>{const s=e._$AA.parentNode,r=t===void 0?e._$AB:t._$AA;if(i===void 0){const o=s.insertBefore(As(),r),n=s.insertBefore(As(),r);i=new Ed(o,n,e,e.options)}else{const o=i._$AB.nextSibling,n=i._$AM,a=n!==e;if(a){let l;i._$AQ?.(e),i._$AM=e,i._$AP!==void 0&&(l=e._$AU)!==n._$AU&&i._$AP(l)}if(o!==r||a){let l=i._$AA;for(;l!==o;){const d=Is(l).nextSibling;Is(s).insertBefore(l,r),l=d}}}return i},fe=(e,t,i=e)=>(e._$AI(t,i),e),Dd={},_d=(e,t=Dd)=>e._$AH=t,Ld=e=>e._$AH,Ht=e=>{e._$AR(),e._$AA.remove()};const Rs=(e,t,i)=>{const s=new Map;for(let r=t;r<=i;r++)s.set(e[r],r);return s},Od=Ai(class extends Ri{constructor(e){if(super(e),e.type!==Ii.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let s;i===void 0?i=t:t!==void 0&&(s=t);const r=[],o=[];let n=0;for(const a of e)r[n]=s?s(a,n):n,o[n]=i(a,n),n++;return{values:o,keys:r}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,s]){const r=Ld(e),{values:o,keys:n}=this.dt(t,i,s);if(!Array.isArray(r))return this.ut=n,o;const a=this.ut??=[],l=[];let d,u,p=0,f=r.length-1,g=0,v=o.length-1;for(;p<=f&&g<=v;)if(r[p]===null)p++;else if(r[f]===null)f--;else if(a[p]===n[g])l[g]=fe(r[p],o[g]),p++,g++;else if(a[f]===n[v])l[v]=fe(r[f],o[v]),f--,v--;else if(a[p]===n[v])l[v]=fe(r[p],o[v]),Fe(e,l[v+1],r[p]),p++,v--;else if(a[f]===n[g])l[g]=fe(r[f],o[g]),Fe(e,r[p],r[f]),f--,g++;else if(d===void 0&&(d=Rs(n,g,v),u=Rs(a,p,f)),d.has(a[p]))if(d.has(a[f])){const _=u.get(n[g]),$e=_!==void 0?r[_]:null;if($e===null){const _e=Fe(e,r[p]);fe(_e,o[g]),l[g]=_e}else l[g]=fe($e,o[g]),Fe(e,r[p],$e),r[_]=null;g++}else Ht(r[f]),f--;else Ht(r[p]),p++;for(;g<=v;){const _=Fe(e,l[v+1]);fe(_,o[g]),l[g++]=_}for(;p<=f;){const _=r[p++];_!==null&&Ht(_)}return this.ut=n,_d(e,l),he}}),Wd="pi-web:chat-groups:",jd={read(e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem(Ms(e));return t===null||t===""?void 0:Fd(JSON.parse(t))}catch{return}},write(e,t){try{if(typeof localStorage>"u")return;localStorage.setItem(Ms(e),JSON.stringify(t))}catch{}}};class Nd{constructor(t=jd){this.storage=t,this.sessionId="",this.openGroupKeys=new Set,this.closedDefaultOpenGroupKeys=new Set}syncSession(t){if(this.sessionId===t)return;this.sessionId=t;const i=t===""?void 0:this.storage.read(t);this.openGroupKeys=new Set(i?.open??[]),this.closedDefaultOpenGroupKeys=new Set(i?.closedDefaultOpen??[])}isOpen(t,i){return i?!this.closedDefaultOpenGroupKeys.has(t):this.openGroupKeys.has(t)}applyToggle(t,i,s){const r=this.isOpen(t,s),o=new Set(this.openGroupKeys),n=new Set(this.closedDefaultOpenGroupKeys);return s?(o.delete(t),i?n.delete(t):n.add(t)):(n.delete(t),i?o.add(t):o.delete(t)),(s?!n.has(t):o.has(t))===r&&Es(o,this.openGroupKeys)&&Es(n,this.closedDefaultOpenGroupKeys)?!1:(this.openGroupKeys=o,this.closedDefaultOpenGroupKeys=n,this.persist(),!0)}snapshot(){return{open:[...this.openGroupKeys],closedDefaultOpen:[...this.closedDefaultOpenGroupKeys]}}persist(){this.sessionId!==""&&this.storage.write(this.sessionId,this.snapshot())}}function Ms(e){return`${Wd}${e}`}function Fd(e){if(Array.isArray(e))return{open:Ut(e),closedDefaultOpen:[]};if(Bd(e))return{open:Array.isArray(e.open)?Ut(e.open):[],closedDefaultOpen:Array.isArray(e.closedDefaultOpen)?Ut(e.closedDefaultOpen):[]}}function Ut(e){return e.filter(t=>typeof t=="string")}function Es(e,t){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}function Bd(e){return typeof e=="object"&&e!==null}function zd(e,t=0){const i=[];let s=[],r=0;const o=(a,l)=>{s.length||(r=l),s.push(a)},n=()=>{s.length&&(i.push({kind:"group",messages:s,startIndex:r,endIndex:r+s.length-1}),s=[])};return e.forEach((a,l)=>{const d=a.parts.filter(g=>Ds(a,g)),u=a.parts.filter(g=>!Ds(a,g)),p=t+l,f={...a.source===void 0?{}:{source:a.source},...a.meta===void 0?{}:{meta:a.meta}};if(u.length&&o({role:a.role,parts:u,...f},p),d.length){n();const g=d.every(v=>v.type==="skillRead")?"skill":a.role;i.push({kind:"message",message:{role:g,parts:d,...f},index:p})}}),n(),i}function qd(e){if(e.every(s=>s.source==="compaction"))return`${String(e.length)} history compaction ${e.length===1?"summary":"summaries"}`;if(e.every(s=>s.source==="branch_summary"))return`${String(e.length)} branch ${e.length===1?"summary":"summaries"}`;const t=e.reduce((s,r)=>(s[r.role]=(s[r.role]??0)+1,s),{}),i=Object.entries(t).map(([s,r])=>`${String(r)} ${s}`).join(" · ");return`${String(e.length)} ${e.length===1?"event":"events"}${i!==""?` · ${i}`:""}`}function Ds(e,t){return e.source==="compaction"||e.source==="branch_summary"?!1:t.type==="skillInvocation"||t.type==="skillRead"?!0:t.type==="text"&&(e.role==="user"||e.role==="assistant"||e.role==="system"||e.role==="bash")}const Hd=30;function Ud(e,t){const i=Gd(Jd(e,t)),s={distanceFromBottom:e.scrollHeight-e.scrollTop};return i===void 0?s:{...s,markerId:i.id,markerOffset:i.offset}}function Vd(e,t,i){if(i!==void 0&&t.markerOffset!==void 0){const s=i.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTop+=Kd(s,t.markerOffset);return}e.scrollTop=Qd(e.scrollHeight,t.distanceFromBottom)}function Gd(e){let t,i=Number.NEGATIVE_INFINITY,s,r=Number.POSITIVE_INFINITY;for(const o of e)o.offset<=0&&o.offset>=i?(t=o,i=o.offset):o.offset>0&&o.offset<r&&(s=o,r=o.offset);return t??s}function Kd(e,t){return e-t}function Qd(e,t){return Math.max(0,e-t)}function Jd(e,t){const i=e.getBoundingClientRect().top;return t.flatMap(s=>{const r=s.dataset.markerId;return r===void 0?[]:[{id:r,offset:s.getBoundingClientRect().top-i}]})}const Zd=600,Xd=1;function Yd(e){return!e.hasMore||e.loadingMore||!e.canRequest||e.clientHeight<=0?!1:ep(e)||tp(e)}function ep(e){return e.scrollTop<(e.topThreshold??Math.max(Zd,e.clientHeight))}function tp(e){return e.scrollHeight<=e.clientHeight+Xd}const ip="pi-web:chat-scroll:",sp=180,rp=48,op=2,np={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)}},ap={setTimeout(e,t){return window.setTimeout(e,t)},clearTimeout(e){window.clearTimeout(e)}};class lp{constructor(t=np,i=ap){this.storage=t,this.scheduler=i}dispose(){this.clearScheduledSave()}clearScheduledSave(){this.saveTimer!==void 0&&(this.scheduler.clearTimeout(this.saveTimer),this.saveTimer=void 0)}scheduleSave(t,i,s=sp){this.clearScheduledSave(),this.saveTimer=this.scheduler.setTimeout(()=>{this.saveTimer=void 0,i(t)},s)}savePosition(t,i,s,r=op){if(t===""||i===void 0||!Gt(i))return"skipped";try{if(Br(i,r)){const a={mode:"bottom"};return this.storage.setItem(Vt(t),JSON.stringify(a)),"saved"}const o=pp(i,s);if(o===void 0)return"skipped";const n=dp(i,o);return this.storage.setItem(Vt(t),JSON.stringify(n)),"saved"}catch{return"skipped"}}restorePosition(t,i,s,r){const o=this.readPosition(t);return o===void 0?this.scrollToBottom(i):this.restoreExplicitPosition(o,i,s,r)}restoreExplicitPosition(t,i,s,r){if(t.mode==="bottom")return this.scrollToBottom(i);if(i===void 0||!Gt(i))return{status:"skipped"};const o=hp(s,t.anchorId);if(o===void 0)return r?.fallbackToBottom===!1?{status:"missing",position:t}:this.scrollToBottom(i);const n=i.getBoundingClientRect().top,a=o.getBoundingClientRect().top-n;return i.scrollTop+=a-t.offset,{status:"restored"}}readPosition(t){if(t!=="")try{const i=this.storage.getItem(Vt(t));if(i===null||i==="")return;const s=JSON.parse(i);return cp(s)?s:void 0}catch{return}}scrollToBottom(t){return t===void 0||!Gt(t)?{status:"skipped"}:(t.scrollTop=t.scrollHeight,{status:"bottom"})}}function Vt(e){return`${ip}${e}`}function cp(e){return typeof e!="object"||e===null||!("mode"in e)?!1:e.mode==="bottom"?!0:e.mode==="anchor"&&"anchorId"in e&&typeof e.anchorId=="string"&&e.anchorId!==""&&"offset"in e&&typeof e.offset=="number"}function Gt(e){return e.clientHeight>0&&e.scrollHeight>0}function Fr(e){return e.scrollHeight-e.scrollTop-e.clientHeight}function Br(e,t=rp){return Fr(e)<t}function dp(e,t){const i=e.getBoundingClientRect().top;return{mode:"anchor",anchorId:Mi(t)??"",offset:t.getBoundingClientRect().top-i}}function pp(e,t){const i=e.getBoundingClientRect();let s,r=Number.NEGATIVE_INFINITY,o,n=Number.POSITIVE_INFINITY;for(const a of t){if(Mi(a)===void 0)continue;const l=a.getBoundingClientRect();if(l.bottom<=l.top||l.bottom<i.top||l.top>i.bottom)continue;const d=l.top-i.top;d<=0&&d>=r?(s=a,r=d):d>0&&d<n&&(o=a,n=d)}return s??o}function _s(e,t){const i=e.getBoundingClientRect();return t.find(s=>{const r=s.getBoundingClientRect();return r.bottom>=i.top&&r.top<=i.bottom})}function hp(e,t){return e.find(i=>Mi(i)===t)}function Mi(e){return e.dataset.scrollAnchorId!==void 0&&e.dataset.scrollAnchorId!==""?e.dataset.scrollAnchorId:void 0}var up=Object.defineProperty,fp=Object.getOwnPropertyDescriptor,Ei=(e,t,i,s)=>{for(var r=s>1?void 0:s?fp(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&up(t,i,r),r};let Je=class extends R{constructor(){super(...arguments),this.positionPercent=0,this.loadedPercent=100}render(){const e=Ls(this.positionPercent),t=Ls(this.loadedPercent),i=`Message position: about ${String(Math.round(e))}% through conversation. ${String(Math.round(t))}% of messages loaded.`;return c`
|
|
637
|
+
<div
|
|
638
|
+
class="meter"
|
|
639
|
+
style=${`--position:${e.toFixed(2)}%;`}
|
|
640
|
+
role="meter"
|
|
641
|
+
aria-label=${i}
|
|
642
|
+
aria-valuemin="0"
|
|
643
|
+
aria-valuemax="100"
|
|
644
|
+
aria-valuenow=${String(Math.round(e))}
|
|
645
|
+
title=${i}
|
|
646
|
+
>
|
|
647
|
+
<div class="track" aria-hidden="true">
|
|
648
|
+
<div class="progress"></div>
|
|
649
|
+
<div class="marker"></div>
|
|
650
|
+
</div>
|
|
651
|
+
</div>
|
|
652
|
+
`}};Je.styles=V`
|
|
653
|
+
:host { position: absolute; top: -4px; left: 16px; right: 16px; z-index: 6; display: block; height: 12px; opacity: .58; transition: opacity .15s ease; }
|
|
654
|
+
:host(:hover), :host(:focus-within) { opacity: .92; }
|
|
655
|
+
.meter { height: 100%; }
|
|
656
|
+
.track { position: relative; height: 4px; margin-top: 4px; border-radius: 999px; background: color-mix(in srgb, var(--pi-border-muted) 34%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--pi-bg) 55%, transparent); }
|
|
657
|
+
.progress { position: absolute; left: 0; width: var(--position); top: 0; bottom: 0; border-radius: 999px; background: color-mix(in srgb, var(--pi-accent) 42%, var(--pi-border-muted)); }
|
|
658
|
+
.marker { position: absolute; left: var(--position); top: 50%; width: 10px; height: 10px; border: 2px solid var(--pi-bg); border-radius: 50%; background: var(--pi-accent); box-shadow: 0 2px 8px var(--pi-shadow); transform: translate(-50%, -50%); }
|
|
659
|
+
`;Ei([h({type:Number})],Je.prototype,"positionPercent",2);Ei([h({type:Number})],Je.prototype,"loadedPercent",2);Je=Ei([F("conversation-meter")],Je);function Ls(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}class si extends Ri{constructor(t){if(super(t),this.it=A,t.type!==Ii.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===A||t==null)return this._t=void 0,this.it=t;if(t===he)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const i=[t];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}}si.directiveName="unsafeHTML",si.resultType=1;const mp=Ai(si);function Di(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ke=Di();function zr(e){ke=e}var ge={exec:()=>null};function S(e,t=""){let i=typeof e=="string"?e:e.source,s={replace:(r,o)=>{let n=typeof o=="string"?o:o.source;return n=n.replace(N.caret,"$1"),i=i.replace(r,n),s},getRegex:()=>new RegExp(i,t)};return s}var gp=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),N={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},vp=/^(?:[ \t]*(?:\n|$))+/,bp=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,wp=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ye=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,yp=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_i=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,qr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Hr=S(qr).replace(/bull/g,_i).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(),xp=S(qr).replace(/bull/g,_i).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(),Li=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kp=/^[^\n]+/,Oi=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Sp=S(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Oi).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),$p=S(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_i).getRegex(),Et="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",Wi=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pp=S("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Wi).replace("tag",Et).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ur=S(Li).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Et).getRegex(),Tp=S(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ur).getRegex(),ji={blockquote:Tp,code:bp,def:Sp,fences:wp,heading:yp,hr:Ye,html:Pp,lheading:Hr,list:$p,newline:vp,paragraph:Ur,table:ge,text:kp},Os=S("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ye).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",Et).getRegex(),Cp={...ji,lheading:xp,table:Os,paragraph:S(Li).replace("hr",Ye).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Os).replace("blockquote"," {0,3}>").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",Et).getRegex()},Ip={...ji,html:S(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Wi).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:ge,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:S(Li).replace("hr",Ye).replace("heading",` *#{1,6} *[^
|
|
660
|
+
]`).replace("lheading",Hr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ap=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Rp=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vr=/^( {2,}|\\)\n(?!\s*$)/,Mp=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,De=/[\p{P}\p{S}]/u,Dt=/[\s\p{P}\p{S}]/u,Ni=/[^\s\p{P}\p{S}]/u,Ep=S(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Dt).getRegex(),Gr=/(?!~)[\p{P}\p{S}]/u,Dp=/(?!~)[\s\p{P}\p{S}]/u,_p=/(?:[^\s\p{P}\p{S}]|~)/u,Lp=S(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",gp?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Kr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Op=S(Kr,"u").replace(/punct/g,De).getRegex(),Wp=S(Kr,"u").replace(/punct/g,Gr).getRegex(),Qr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",jp=S(Qr,"gu").replace(/notPunctSpace/g,Ni).replace(/punctSpace/g,Dt).replace(/punct/g,De).getRegex(),Np=S(Qr,"gu").replace(/notPunctSpace/g,_p).replace(/punctSpace/g,Dp).replace(/punct/g,Gr).getRegex(),Fp=S("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ni).replace(/punctSpace/g,Dt).replace(/punct/g,De).getRegex(),Bp=S(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,De).getRegex(),zp="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",qp=S(zp,"gu").replace(/notPunctSpace/g,Ni).replace(/punctSpace/g,Dt).replace(/punct/g,De).getRegex(),Hp=S(/\\(punct)/,"gu").replace(/punct/g,De).getRegex(),Up=S(/^<(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(),Vp=S(Wi).replace("(?:-->|$)","-->").getRegex(),Gp=S("^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",Vp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),St=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Kp=S(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",St).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Jr=S(/^!?\[(label)\]\[(ref)\]/).replace("label",St).replace("ref",Oi).getRegex(),Zr=S(/^!?\[(ref)\](?:\[\])?/).replace("ref",Oi).getRegex(),Qp=S("reflink|nolink(?!\\()","g").replace("reflink",Jr).replace("nolink",Zr).getRegex(),Ws=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Fi={_backpedal:ge,anyPunctuation:Hp,autolink:Up,blockSkip:Lp,br:Vr,code:Rp,del:ge,delLDelim:ge,delRDelim:ge,emStrongLDelim:Op,emStrongRDelimAst:jp,emStrongRDelimUnd:Fp,escape:Ap,link:Kp,nolink:Zr,punctuation:Ep,reflink:Jr,reflinkSearch:Qp,tag:Gp,text:Mp,url:ge},Jp={...Fi,link:S(/^!?\[(label)\]\((.*?)\)/).replace("label",St).getRegex(),reflink:S(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",St).getRegex()},ri={...Fi,emStrongRDelimAst:Np,emStrongLDelim:Wp,delLDelim:Bp,delRDelim:qp,url:S(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ws).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:S(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ws).getRegex()},Zp={...ri,br:S(Vr).replace("{2,}","*").getRegex(),text:S(ri.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ot={normal:ji,gfm:Cp,pedantic:Ip},Be={normal:Fi,gfm:ri,breaks:Zp,pedantic:Jp},Xp={"&":"&","<":"<",">":">",'"':""","'":"'"},js=e=>Xp[e];function re(e,t){if(t){if(N.escapeTest.test(e))return e.replace(N.escapeReplace,js)}else if(N.escapeTestNoEncode.test(e))return e.replace(N.escapeReplaceNoEncode,js);return e}function Ns(e){try{e=encodeURI(e).replace(N.percentDecode,"%")}catch{return null}return e}function Fs(e,t){let i=e.replace(N.findPipe,(o,n,a)=>{let l=!1,d=n;for(;--d>=0&&a[d]==="\\";)l=!l;return l?"|":" |"}),s=i.split(N.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(N.slashPipe,"|");return s}function de(e,t,i){let s=e.length;if(s===0)return"";let r=0;for(;r<s&&e.charAt(s-r-1)===t;)r++;return e.slice(0,s-r)}function Bs(e){let t=e.split(`
|
|
661
|
+
`),i=t.length-1;for(;i>=0&&N.blankLine.test(t[i]);)i--;return t.length-i<=2?e:t.slice(0,i+1).join(`
|
|
662
|
+
`)}function Yp(e,t){if(e.indexOf(t[1])===-1)return-1;let i=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])i++;else if(e[s]===t[1]&&(i--,i<0))return s;return i>0?-2:-1}function eh(e,t=0){let i=t,s="";for(let r of e)if(r===" "){let o=4-i%4;s+=" ".repeat(o),i+=o}else s+=r,i++;return s}function zs(e,t,i,s,r){let o=t.href,n=t.title||null,a=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:i,href:o,title:n,text:a,tokens:s.inlineTokens(a)};return s.state.inLink=!1,l}function th(e,t,i){let s=e.match(i.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
|
|
663
|
+
`).map(o=>{let n=o.match(i.other.beginningSpace);if(n===null)return o;let[a]=n;return a.length>=r.length?o.slice(r.length):o}).join(`
|
|
664
|
+
`)}var $t=class{options;rules;lexer;constructor(e){this.options=e||ke}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let i=this.options.pedantic?t[0]:Bs(t[0]),s=i.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:i,codeBlockStyle:"indented",text:s}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let i=t[0],s=th(i,t[3]||"",this.rules);return{type:"code",raw:i,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let i=t[2].trim();if(this.rules.other.endingHash.test(i)){let s=de(i,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(i=s.trim())}return{type:"heading",raw:de(t[0],`
|
|
665
|
+
`),depth:t[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:de(t[0],`
|
|
666
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let i=de(t[0],`
|
|
667
|
+
`).split(`
|
|
668
|
+
`),s="",r="",o=[];for(;i.length>0;){let n=!1,a=[],l;for(l=0;l<i.length;l++)if(this.rules.other.blockquoteStart.test(i[l]))a.push(i[l]),n=!0;else if(!n)a.push(i[l]);else break;i=i.slice(l);let d=a.join(`
|
|
669
|
+
`),u=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
670
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
671
|
+
${d}`:d,r=r?`${r}
|
|
672
|
+
${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,o,!0),this.lexer.state.top=p,i.length===0)break;let f=o.at(-1);if(f?.type==="code")break;if(f?.type==="blockquote"){let g=f,v=g.raw+`
|
|
673
|
+
`+i.join(`
|
|
674
|
+
`),_=this.blockquote(v);o[o.length-1]=_,s=s.substring(0,s.length-g.raw.length)+_.raw,r=r.substring(0,r.length-g.text.length)+_.text;break}else if(f?.type==="list"){let g=f,v=g.raw+`
|
|
675
|
+
`+i.join(`
|
|
676
|
+
`),_=this.list(v);o[o.length-1]=_,s=s.substring(0,s.length-f.raw.length)+_.raw,r=r.substring(0,r.length-g.raw.length)+_.raw,i=v.substring(o.at(-1).raw.length).split(`
|
|
677
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim(),s=i.length>1,r={type:"list",raw:"",ordered:s,start:s?+i.slice(0,-1):"",loose:!1,items:[]};i=s?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=s?i:"[*+-]");let o=this.rules.other.listItemRegex(i),n=!1;for(;e;){let l=!1,d="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let p=eh(t[2].split(`
|
|
678
|
+
`,1)[0],t[1].length),f=e.split(`
|
|
679
|
+
`,1)[0],g=!p.trim(),v=0;if(this.options.pedantic?(v=2,u=p.trimStart()):g?v=t[1].length+1:(v=p.search(this.rules.other.nonSpaceChar),v=v>4?1:v,u=p.slice(v),v+=t[1].length),g&&this.rules.other.blankLine.test(f)&&(d+=f+`
|
|
680
|
+
`,e=e.substring(f.length+1),l=!0),!l){let _=this.rules.other.nextBulletRegex(v),$e=this.rules.other.hrRegex(v),_e=this.rules.other.fencesBeginRegex(v),qi=this.rules.other.headingBeginRegex(v),io=this.rules.other.htmlBeginRegex(v),so=this.rules.other.blockquoteBeginRegex(v);for(;e;){let Ot=e.split(`
|
|
681
|
+
`,1)[0],Le;if(f=Ot,this.options.pedantic?(f=f.replace(this.rules.other.listReplaceNesting," "),Le=f):Le=f.replace(this.rules.other.tabCharGlobal," "),_e.test(f)||qi.test(f)||io.test(f)||so.test(f)||_.test(f)||$e.test(f))break;if(Le.search(this.rules.other.nonSpaceChar)>=v||!f.trim())u+=`
|
|
682
|
+
`+Le.slice(v);else{if(g||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_e.test(p)||qi.test(p)||$e.test(p))break;u+=`
|
|
683
|
+
`+f}g=!f.trim(),d+=Ot+`
|
|
684
|
+
`,e=e.substring(Ot.length+1),p=Le.slice(v)}}r.loose||(n?r.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(n=!0)),r.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=d}let a=r.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let d=l.tokens[0];if(l.task&&(d?.type==="text"||d?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),d.raw=d.raw.replace(this.rules.other.listReplaceTask,""),d.text=d.text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let p={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=p.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=p.raw+l.tokens[0].raw,l.tokens[0].text=p.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(p)):l.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):l.tokens.unshift(p)}}else l.task&&(l.task=!1);if(!r.loose){let u=l.tokens.filter(f=>f.type==="space"),p=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));r.loose=p}}if(r.loose)for(let l of r.items){l.loose=!0;for(let d of l.tokens)d.type==="text"&&(d.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t){let i=Bs(t[0]);return{type:"html",block:!0,raw:i,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:i}}}def(e){let t=this.rules.block.def.exec(e);if(t){let i=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:i,raw:de(t[0],`
|
|
685
|
+
`),href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let i=Fs(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
686
|
+
`):[],o={type:"table",raw:de(t[0],`
|
|
687
|
+
`),header:[],align:[],rows:[]};if(i.length===s.length){for(let n of s)this.rules.other.tableAlignRight.test(n)?o.align.push("right"):this.rules.other.tableAlignCenter.test(n)?o.align.push("center"):this.rules.other.tableAlignLeft.test(n)?o.align.push("left"):o.align.push(null);for(let n=0;n<i.length;n++)o.header.push({text:i[n],tokens:this.lexer.inline(i[n]),header:!0,align:o.align[n]});for(let n of r)o.rows.push(Fs(n,o.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:o.align[l]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let i=t[1].trim();return{type:"heading",raw:de(t[0],`
|
|
688
|
+
`),depth:t[2].charAt(0)==="="?1:2,text:i,tokens:this.lexer.inline(i)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let i=t[1].charAt(t[1].length-1)===`
|
|
689
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:i,tokens:this.lexer.inline(i)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let i=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;let o=de(i.slice(0,-1),"\\");if((i.length-o.length)%2===0)return}else{let o=Yp(t[2],"()");if(o===-2)return;if(o>-1){let n=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?s=s.slice(1):s=s.slice(1,-1)),zs(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){let s=(i[2]||i[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let o=i[0].charAt(0);return{type:"text",raw:o,text:o}}return zs(i,r,i[0],this.lexer,this.rules)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&i.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!i||this.rules.inline.punctuation.exec(i))){let r=[...s[0]].length-1,o,n,a=r,l=0,d=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+r);(s=d.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(n=[...o].length,s[3]||s[4]){a+=n;continue}else if((s[5]||s[6])&&r%3&&!((r+n)%3)){l+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a+l);let u=[...s[0]][0].length,p=e.slice(0,r+s.index+u+n);if(Math.min(r,n)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let f=p.slice(2,-2);return{type:"strong",raw:p,text:f,tokens:this.lexer.inlineTokens(f)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(i),r=this.rules.other.startingSpaceChar.test(i)&&this.rules.other.endingSpaceChar.test(i);return s&&r&&(i=i.substring(1,i.length-1)),{type:"codespan",raw:t[0],text:i}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,i=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!i||this.rules.inline.punctuation.exec(i))){let r=[...s[0]].length-1,o,n,a=r,l=this.rules.inline.delRDelim;for(l.lastIndex=0,t=t.slice(-1*e.length+r);(s=l.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(n=[...o].length,n!==r))continue;if(s[3]||s[4]){a+=n;continue}if(a-=n,a>0)continue;n=Math.min(n,n+a);let d=[...s[0]][0].length,u=e.slice(0,r+s.index+d+n),p=u.slice(r,-r);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let i,s;return t[2]==="@"?(i=t[1],s="mailto:"+i):(i=t[1],s=i),{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let i,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let i=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:i}}}},Y=class oi{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||ke,this.options.tokenizer=this.options.tokenizer||new $t,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let i={other:N,block:ot.normal,inline:Be.normal};this.options.pedantic?(i.block=ot.pedantic,i.inline=Be.pedantic):this.options.gfm&&(i.block=ot.gfm,this.options.breaks?i.inline=Be.breaks:i.inline=Be.gfm),this.tokenizer.rules=i}static get rules(){return{block:ot,inline:Be}}static lex(t,i){return new oi(i).lex(t)}static lexInline(t,i){return new oi(i).inlineTokens(t)}lex(t){t=t.replace(N.carriageReturn,`
|
|
690
|
+
`),this.blockTokens(t,this.tokens);for(let i=0;i<this.inlineQueue.length;i++){let s=this.inlineQueue[i];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,i=[],s=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(N.tabCharGlobal," ").replace(N.spaceLine,""));let r=1/0;for(;t;){if(t.length<r)r=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(a=>(o=a.call({lexer:this},t,i))?(t=t.substring(o.raw.length),i.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let a=i.at(-1);o.raw.length===1&&a!==void 0?a.raw+=`
|
|
691
|
+
`:i.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
692
|
+
`)?"":`
|
|
693
|
+
`)+o.raw,a.text+=`
|
|
694
|
+
`+o.text,this.inlineQueue.at(-1).src=a.text):i.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
695
|
+
`)?"":`
|
|
696
|
+
`)+o.raw,a.text+=`
|
|
697
|
+
`+o.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},i.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),i.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),i.push(o);continue}let n=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),d;this.options.extensions.startBlock.forEach(u=>{d=u.call({lexer:this},l),typeof d=="number"&&d>=0&&(a=Math.min(a,d))}),a<1/0&&a>=0&&(n=t.substring(0,a+1))}if(this.state.top&&(o=this.tokenizer.paragraph(n))){let a=i.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
698
|
+
`)?"":`
|
|
699
|
+
`)+o.raw,a.text+=`
|
|
700
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):i.push(o),s=n.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let a=i.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
701
|
+
`)?"":`
|
|
702
|
+
`)+o.raw,a.text+=`
|
|
703
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):i.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,i}inline(t,i=[]){return this.inlineQueue.push({src:t,tokens:i}),i}inlineTokens(t,i=[]){this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let d=Object.keys(this.tokens.links);if(d.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)d.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)o=r[2]?r[2].length:0,s=s.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let n=!1,a="",l=1/0;for(;t;){if(t.length<l)l=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}n||(a=""),n=!1;let d;if(this.options.extensions?.inline?.some(p=>(d=p.call({lexer:this},t,i))?(t=t.substring(d.raw.length),i.push(d),!0):!1))continue;if(d=this.tokenizer.escape(t)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.tag(t)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.link(t)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(d.raw.length);let p=i.at(-1);d.type==="text"&&p?.type==="text"?(p.raw+=d.raw,p.text+=d.text):i.push(d);continue}if(d=this.tokenizer.emStrong(t,s,a)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.codespan(t)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.br(t)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.del(t,s,a)){t=t.substring(d.raw.length),i.push(d);continue}if(d=this.tokenizer.autolink(t)){t=t.substring(d.raw.length),i.push(d);continue}if(!this.state.inLink&&(d=this.tokenizer.url(t))){t=t.substring(d.raw.length),i.push(d);continue}let u=t;if(this.options.extensions?.startInline){let p=1/0,f=t.slice(1),g;this.options.extensions.startInline.forEach(v=>{g=v.call({lexer:this},f),typeof g=="number"&&g>=0&&(p=Math.min(p,g))}),p<1/0&&p>=0&&(u=t.substring(0,p+1))}if(d=this.tokenizer.inlineText(u)){t=t.substring(d.raw.length),d.raw.slice(-1)!=="_"&&(a=d.raw.slice(-1)),n=!0;let p=i.at(-1);p?.type==="text"?(p.raw+=d.raw,p.text+=d.text):i.push(d);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return i}infiniteLoopError(t){let i="Infinite loop on byte: "+t;if(this.options.silent)console.error(i);else throw new Error(i)}},Pt=class{options;parser;constructor(e){this.options=e||ke}space(e){return""}code({text:e,lang:t,escaped:i}){let s=(t||"").match(N.notSpaceStart)?.[0],r=e.replace(N.endingNewline,"")+`
|
|
704
|
+
`;return s?'<pre><code class="language-'+re(s)+'">'+(i?r:re(r,!0))+`</code></pre>
|
|
705
|
+
`:"<pre><code>"+(i?r:re(r,!0))+`</code></pre>
|
|
706
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
707
|
+
${this.parser.parse(e)}</blockquote>
|
|
708
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
709
|
+
`}hr(e){return`<hr>
|
|
710
|
+
`}list(e){let t=e.ordered,i=e.start,s="";for(let n=0;n<e.items.length;n++){let a=e.items[n];s+=this.listitem(a)}let r=t?"ol":"ul",o=t&&i!==1?' start="'+i+'"':"";return"<"+r+o+`>
|
|
711
|
+
`+s+"</"+r+`>
|
|
712
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
713
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
714
|
+
`}table(e){let t="",i="";for(let r=0;r<e.header.length;r++)i+=this.tablecell(e.header[r]);t+=this.tablerow({text:i});let s="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];i="";for(let n=0;n<o.length;n++)i+=this.tablecell(o[n]);s+=this.tablerow({text:i})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
715
|
+
<thead>
|
|
716
|
+
`+t+`</thead>
|
|
717
|
+
`+s+`</table>
|
|
718
|
+
`}tablerow({text:e}){return`<tr>
|
|
719
|
+
${e}</tr>
|
|
720
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),i=e.header?"th":"td";return(e.align?`<${i} align="${e.align}">`:`<${i}>`)+t+`</${i}>
|
|
721
|
+
`}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>${re(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:i}){let s=this.parser.parseInline(i),r=Ns(e);if(r===null)return s;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+re(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:i,tokens:s}){s&&(i=this.parser.parseInline(s,this.parser.textRenderer));let r=Ns(e);if(r===null)return re(i);e=r;let o=`<img src="${e}" alt="${re(i)}"`;return t&&(o+=` title="${re(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:re(e.text)}},Bi=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}},ee=class ni{options;renderer;textRenderer;constructor(t){this.options=t||ke,this.options.renderer=this.options.renderer||new Pt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Bi}static parse(t,i){return new ni(i).parse(t)}static parseInline(t,i){return new ni(i).parseInline(t)}parse(t){this.renderer.parser=this;let i="";for(let s=0;s<t.length;s++){let r=t[s];if(this.options.extensions?.renderers?.[r.type]){let n=r,a=this.options.extensions.renderers[n.type].call({parser:this},n);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(n.type)){i+=a||"";continue}}let o=r;switch(o.type){case"space":{i+=this.renderer.space(o);break}case"hr":{i+=this.renderer.hr(o);break}case"heading":{i+=this.renderer.heading(o);break}case"code":{i+=this.renderer.code(o);break}case"table":{i+=this.renderer.table(o);break}case"blockquote":{i+=this.renderer.blockquote(o);break}case"list":{i+=this.renderer.list(o);break}case"checkbox":{i+=this.renderer.checkbox(o);break}case"html":{i+=this.renderer.html(o);break}case"def":{i+=this.renderer.def(o);break}case"paragraph":{i+=this.renderer.paragraph(o);break}case"text":{i+=this.renderer.text(o);break}default:{let n='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return i}parseInline(t,i=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=a||"";continue}}let n=o;switch(n.type){case"escape":{s+=i.text(n);break}case"html":{s+=i.html(n);break}case"link":{s+=i.link(n);break}case"image":{s+=i.image(n);break}case"checkbox":{s+=i.checkbox(n);break}case"strong":{s+=i.strong(n);break}case"em":{s+=i.em(n);break}case"codespan":{s+=i.codespan(n);break}case"br":{s+=i.br(n);break}case"del":{s+=i.del(n);break}case"text":{s+=i.text(n);break}default:{let a='Token with "'+n.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return s}},qe=class{options;block;constructor(e){this.options=e||ke}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?Y.lex:Y.lexInline}provideParser(e=this.block){return e?ee.parse:ee.parseInline}},ih=class{defaults=Di();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ee;Renderer=Pt;TextRenderer=Bi;Lexer=Y;Tokenizer=$t;Hooks=qe;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(let s of e)switch(i=i.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let o of r.header)i=i.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let n of o)i=i.concat(this.walkTokens(n.tokens,t));break}case"list":{let r=s;i=i.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(o=>{let n=r[o].flat(1/0);i=i.concat(this.walkTokens(n,t))}):r.tokens&&(i=i.concat(this.walkTokens(r.tokens,t)))}}return i}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(i=>{let s={...i};if(s.async=this.defaults.async||s.async||!1,i.extensions&&(i.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...n){let a=r.renderer.apply(this,n);return a===!1&&(a=o.apply(this,n)),a}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),i.renderer){let r=this.defaults.renderer||new Pt(this.defaults);for(let o in i.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let n=o,a=i.renderer[n],l=r[n];r[n]=(...d)=>{let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u||""}}s.renderer=r}if(i.tokenizer){let r=this.defaults.tokenizer||new $t(this.defaults);for(let o in i.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let n=o,a=i.tokenizer[n],l=r[n];r[n]=(...d)=>{let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u}}s.tokenizer=r}if(i.hooks){let r=this.defaults.hooks||new qe;for(let o in i.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let n=o,a=i.hooks[n],l=r[n];qe.passThroughHooks.has(o)?r[n]=d=>{if(this.defaults.async&&qe.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await a.call(r,d);return l.call(r,p)})();let u=a.call(r,d);return l.call(r,u)}:r[n]=(...d)=>{if(this.defaults.async)return(async()=>{let p=await a.apply(r,d);return p===!1&&(p=await l.apply(r,d)),p})();let u=a.apply(r,d);return u===!1&&(u=l.apply(r,d)),u}}s.hooks=r}if(i.walkTokens){let r=this.defaults.walkTokens,o=i.walkTokens;s.walkTokens=function(n){let a=[];return a.push(o.call(this,n)),r&&(a=a.concat(r.call(this,n))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Y.lex(e,t??this.defaults)}parser(e,t){return ee.parse(e,t??this.defaults)}parseMarkdown(e){return(t,i)=>{let s={...i},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let n=r.hooks?await r.hooks.preprocess(t):t,a=await(r.hooks?await r.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(n,r),l=r.hooks?await r.hooks.processAllTokens(a):a;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let d=await(r.hooks?await r.hooks.provideParser(e):e?ee.parse:ee.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(d):d})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let n=(r.hooks?r.hooks.provideLexer(e):e?Y.lex:Y.lexInline)(t,r);r.hooks&&(n=r.hooks.processAllTokens(n)),r.walkTokens&&this.walkTokens(n,r.walkTokens);let a=(r.hooks?r.hooks.provideParser(e):e?ee.parse:ee.parseInline)(n,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(n){return o(n)}}}onError(e,t){return i=>{if(i.message+=`
|
|
722
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+re(i.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(i);throw i}}},ye=new ih;function $(e,t){return ye.parse(e,t)}$.options=$.setOptions=function(e){return ye.setOptions(e),$.defaults=ye.defaults,zr($.defaults),$};$.getDefaults=Di;$.defaults=ke;$.use=function(...e){return ye.use(...e),$.defaults=ye.defaults,zr($.defaults),$};$.walkTokens=function(e,t){return ye.walkTokens(e,t)};$.parseInline=ye.parseInline;$.Parser=ee;$.parser=ee.parse;$.Renderer=Pt;$.TextRenderer=Bi;$.Lexer=Y;$.lexer=Y.lex;$.Tokenizer=$t;$.Hooks=qe;$.parse=$;$.options;$.setOptions;$.use;$.walkTokens;$.parseInline;ee.parse;Y.lex;const Xr=new $.Renderer;Xr.html=({text:e})=>oh(e);const sh=300,ze=new Map;function rh(e){const t=ze.get(e);if(t!==void 0)return t;const i=$.parse(e,{async:!1,breaks:!0,gfm:!0,renderer:Xr}),s=nh(i);if(ze.set(e,s),ze.size>sh){const r=ze.keys().next().value;r!==void 0&&ze.delete(r)}return s}function oh(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function nh(e){const t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("script, style, iframe, object, embed").forEach(i=>{i.remove()}),t.content.querySelectorAll("*").forEach(i=>{for(const s of[...i.attributes]){const r=s.name.toLowerCase();r.startsWith("on")&&i.removeAttribute(s.name),(r==="href"||r==="src")&&!ah(s.value)&&i.removeAttribute(s.name)}i.tagName==="A"&&(i.setAttribute("target","_blank"),i.setAttribute("rel","noreferrer noopener"))}),t.innerHTML}function ah(e){if(e.startsWith("#")||e.startsWith("/"))return!0;try{return["http:","https:","mailto:"].includes(new URL(e).protocol)}catch{return!1}}var lh=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,Yr=(e,t,i,s)=>{for(var r=s>1?void 0:s?ch(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&lh(t,i,r),r};let Tt=class extends R{constructor(){super(...arguments),this.text="",this.onFormattedClick=e=>{if(!(e.target instanceof Element))return;const t=e.target.closest(".code-copy-button");if(!(t instanceof HTMLButtonElement))return;const i=t.closest(".code-block-wrapper");if(!(i instanceof HTMLElement))return;const s=i.querySelector("pre code");s instanceof HTMLElement&&this.copyCode(s.textContent,t)},this.onFormattedCopy=e=>{e.clipboardData===null||!hh(dh(this))||(e.clipboardData.setData("text/plain",this.text),e.preventDefault(),e.stopPropagation())}}render(){return c`<div class="formatted" @click=${this.onFormattedClick} @copy=${this.onFormattedCopy}>${mp(rh(this.text))}</div>`}updated(){this.enhanceCodeBlocks()}enhanceCodeBlocks(){this.renderRoot.querySelectorAll("pre").forEach(e=>{if(!(e instanceof HTMLPreElement)||e.parentElement?.classList.contains("code-block-wrapper")===!0||!(e.querySelector("code")instanceof HTMLElement))return;const i=document.createElement("div");i.className="code-block-wrapper";const s=document.createElement("button");s.type="button",s.className="code-copy-button",s.title="Copy code block",s.setAttribute("aria-label","Copy code block");const r=document.createElement("span");r.setAttribute("aria-hidden","true"),r.textContent="⧉",s.append(r),e.before(i),i.append(e,s)})}async copyCode(e,t){const i=await uh(e);this.setCopyButtonState(t,i?"copied":"failed"),window.setTimeout(()=>{this.setCopyButtonState(t,"idle")},1200)}setCopyButtonState(e,t){const i=e.querySelector("span");i!==null&&(i.textContent=t==="copied"?"✓":"⧉");const s=t==="copied"?"Copied code block":t==="failed"?"Failed to copy code block":"Copy code block";e.title=s,e.setAttribute("aria-label",s)}};Tt.styles=fd;Yr([h()],Tt.prototype,"text",2);Tt=Yr([F("formatted-text")],Tt);function dh(e){const t=e.getRootNode();return typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&ph(t)?t.getSelection():e.ownerDocument.getSelection()}function ph(e){return"getSelection"in e&&typeof e.getSelection=="function"}function hh(e){return e!==null&&!e.isCollapsed&&e.toString()!==""}async function uh(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}var fh=Object.defineProperty,mh=Object.getOwnPropertyDescriptor,et=(e,t,i,s)=>{for(var r=s>1?void 0:s?mh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&fh(t,i,r),r};const qs=180;let xe=class extends R{constructor(){super(...arguments),this.showFullDiff=!1,this.copied=!1,this.diffOpen=!0}render(){const e=this.execution;if(e===void 0)return null;const t=e.toolName==="edit",i=gh(e.args),s=vh(e.details),r=e.preview,o=s??r?.diff,n=o===void 0?void 0:bh(o),a=s!==void 0&&r?.diff!==void 0&&s!==r.diff,l=e.status==="error"?e.resultText:r?.error,d=o===void 0?e.resultText:void 0;return c`
|
|
723
|
+
<section class=${`tool-card ${e.status}`}>
|
|
724
|
+
<div class="tool-header">
|
|
725
|
+
<div class="tool-title">
|
|
726
|
+
<span class="status-icon" aria-hidden="true">${yh(e.status)}</span>
|
|
727
|
+
<strong>${e.toolName}</strong>
|
|
728
|
+
${i===void 0?c`<span class="summary">${e.summary}</span>`:c`<span class="path">${i}</span>`}
|
|
729
|
+
</div>
|
|
730
|
+
<div class="tool-meta">
|
|
731
|
+
${Hs(e)===void 0?null:c`<span>${Hs(e)}</span>`}
|
|
732
|
+
${n===void 0?null:c`<span class="diff-stats"><b class="added">+${n.added}</b><span>/</span><b class="removed">-${n.removed}</b></span>`}
|
|
733
|
+
<span class="status-label">${xh(e.status)}</span>
|
|
734
|
+
</div>
|
|
735
|
+
</div>
|
|
736
|
+
|
|
737
|
+
${a?c`<p class="notice">Applied diff differs from the preview.</p>`:null}
|
|
738
|
+
${l===void 0||l===""?null:c`<pre class="error-text">${l}</pre>`}
|
|
739
|
+
${o===void 0?this.renderTextBody(d,e.status==="error"):this.renderDiffBody(o,s===void 0?"Preview diff":"Applied diff")}
|
|
740
|
+
${!t&&o===void 0&&(d===void 0||d==="")?c`<p class="muted">${e.summary}</p>`:null}
|
|
741
|
+
</section>
|
|
742
|
+
`}renderTextBody(e,t){return e===void 0||e===""?null:c`
|
|
743
|
+
<details class="text-body" ?open=${t}>
|
|
744
|
+
<summary>Result</summary>
|
|
745
|
+
<pre>${e}</pre>
|
|
746
|
+
</details>
|
|
747
|
+
`}renderDiffBody(e,t){const i=e.split(`
|
|
748
|
+
`),s=!this.showFullDiff&&i.length>qs,r=s?i.slice(0,qs):i;return c`
|
|
749
|
+
<details class="diff-details" ?open=${this.diffOpen} @toggle=${o=>{this.onDiffToggle(o)}}>
|
|
750
|
+
<summary>
|
|
751
|
+
<span>${t}</span>
|
|
752
|
+
<small>${String(i.length)} ${i.length===1?"line":"lines"}</small>
|
|
753
|
+
</summary>
|
|
754
|
+
<div class="diff-toolbar">
|
|
755
|
+
<span>${s?`Showing ${String(r.length)} of ${String(i.length)} lines`:"Full diff"}</span>
|
|
756
|
+
<button type="button" @click=${()=>{this.copyDiff(e)}}>${this.copied?"Copied":"Copy diff"}</button>
|
|
757
|
+
</div>
|
|
758
|
+
<pre class="diff" aria-label=${t}><code class="diff-content">${r.map(o=>c`<span class=${wh(o)}>${o}</span>`)}</code></pre>
|
|
759
|
+
${s?c`
|
|
760
|
+
<button class="show-more" type="button" @click=${()=>{this.showFullDiff=!0}}>
|
|
761
|
+
Show all ${String(i.length)} diff lines
|
|
762
|
+
</button>
|
|
763
|
+
`:null}
|
|
764
|
+
</details>
|
|
765
|
+
`}onDiffToggle(e){const t=e.currentTarget;t instanceof HTMLDetailsElement&&(this.diffOpen=t.open)}async copyDiff(e){try{await navigator.clipboard.writeText(e),this.copied=!0,window.setTimeout(()=>{this.copied=!1},1200)}catch{this.copied=!1}}};xe.styles=V`
|
|
766
|
+
:host { display: block; width: 100%; max-width: 100%; min-width: 0; color: var(--pi-text); }
|
|
767
|
+
.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); }
|
|
768
|
+
.tool-card.running, .tool-card.pending { border-color: var(--pi-warning-border); background: var(--pi-warning-surface); }
|
|
769
|
+
.tool-card.success { border-color: var(--pi-success-border); background: var(--pi-success-bg); }
|
|
770
|
+
.tool-card.error { border-color: var(--pi-danger); background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); }
|
|
771
|
+
.tool-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
|
|
772
|
+
.tool-title { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; }
|
|
773
|
+
.status-icon { flex: 0 0 auto; color: var(--pi-muted); }
|
|
774
|
+
strong { color: var(--pi-text); }
|
|
775
|
+
.path, .summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pi-accent); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
776
|
+
.summary { color: var(--pi-muted); font-family: inherit; }
|
|
777
|
+
.tool-meta { flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
778
|
+
.diff-stats { display: inline-flex; gap: 3px; }
|
|
779
|
+
.added, .diff .added { color: var(--pi-success); }
|
|
780
|
+
.removed, .diff .removed { color: var(--pi-danger); }
|
|
781
|
+
.status-label { text-transform: uppercase; letter-spacing: .04em; color: var(--pi-muted); }
|
|
782
|
+
.notice { margin: 0; color: var(--pi-warning); }
|
|
783
|
+
.muted { margin: 0; color: var(--pi-muted); }
|
|
784
|
+
.error-text { margin: 0; border: 1px solid var(--pi-danger); border-radius: 7px; background: color-mix(in srgb, var(--pi-danger) 10%, var(--pi-bg)); color: var(--pi-danger); padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
785
|
+
.text-body { border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
786
|
+
.text-body pre { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--pi-text); }
|
|
787
|
+
.diff-details { min-width: 0; max-width: 100%; border-top: 1px solid var(--pi-border-muted); padding-top: 6px; }
|
|
788
|
+
.diff-details > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; color: var(--pi-muted); cursor: pointer; }
|
|
789
|
+
.diff-details > summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
790
|
+
.diff-details > summary small { flex: 0 0 auto; color: var(--pi-dim); }
|
|
791
|
+
.diff-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; margin-top: 8px; color: var(--pi-muted); font-size: 12px; }
|
|
792
|
+
.diff-toolbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
793
|
+
button { border: 1px solid var(--pi-border); border-radius: 6px; background: var(--pi-surface); color: var(--pi-text); padding: 3px 7px; font: 12px system-ui, sans-serif; cursor: pointer; }
|
|
794
|
+
button:hover, button:focus { border-color: var(--pi-accent); }
|
|
795
|
+
.diff { box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; margin: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; border: 1px solid var(--pi-border-muted); border-radius: 7px; background: var(--pi-bg); padding: 8px 0; color: var(--pi-muted); font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.45; }
|
|
796
|
+
.diff-content { display: block; width: max-content; min-width: 100%; }
|
|
797
|
+
.diff span { display: block; min-height: 1.45em; padding: 0 8px; white-space: pre; }
|
|
798
|
+
.diff .context { color: var(--pi-muted); }
|
|
799
|
+
.diff .hunk { color: var(--pi-accent); }
|
|
800
|
+
.diff .file { color: var(--pi-dim); }
|
|
801
|
+
.diff .meta { color: var(--pi-dim); }
|
|
802
|
+
.diff .added { background: color-mix(in srgb, var(--pi-success) 12%, transparent); }
|
|
803
|
+
.diff .removed { background: color-mix(in srgb, var(--pi-danger) 12%, transparent); }
|
|
804
|
+
.show-more { justify-self: start; }
|
|
805
|
+
`;et([h({attribute:!1})],xe.prototype,"execution",2);et([x()],xe.prototype,"showFullDiff",2);et([x()],xe.prototype,"copied",2);et([x()],xe.prototype,"diffOpen",2);xe=et([F("tool-execution-view")],xe);function gh(e){return ai(e,"path")??ai(e,"file_path")}function Hs(e){if(e.toolName!=="edit")return;const t=pt(e.args,"edits");if(Array.isArray(t))return`${String(t.length)} edit${t.length===1?"":"s"}`;if(typeof pt(e.args,"oldText")=="string"&&typeof pt(e.args,"newText")=="string")return"1 edit"}function vh(e){return ai(e,"diff")}function bh(e){let t=0,i=0;for(const s of e.split(`
|
|
806
|
+
`))eo(s)?t++:to(s)&&i++;return{added:t,removed:i}}function wh(e){return eo(e)?"added":to(e)?"removed":e.startsWith("@@")?"hunk":e.startsWith("+++")||e.startsWith("---")?"file":e.startsWith("diff ")||e.startsWith("index ")?"meta":"context"}function eo(e){return e.startsWith("+")&&!e.startsWith("+++")}function to(e){return e.startsWith("-")&&!e.startsWith("---")}function yh(e){return e==="success"?"✓":e==="error"?"✖":e==="running"?"●":"○"}function xh(e){return e==="success"?"done":e==="error"?"failed":e==="running"?"running":"pending"}function kh(e){return typeof e=="object"&&e!==null}function pt(e,t){return kh(e)?e[t]:void 0}function ai(e,t){const i=pt(e,t);return typeof i=="string"?i:void 0}var Sh=Object.defineProperty,$h=Object.getOwnPropertyDescriptor,E=(e,t,i,s)=>{for(var r=s>1?void 0:s?$h(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Sh(t,i,r),r};const Ph=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),Th=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"medium"}),Kt=["You opened this chat while the assistant was already replying. The complete answer will appear shortly.","We joined mid-sentence. Holding the curtain until the full reply is ready.","The assistant started before this tab arrived. We’ll show the full answer when it lands.","Catching the reply in one piece — no spoilers, no half-answers.","The tokens are still assembling themselves. Full answer incoming.","We arrived fashionably late to this response. The complete version will appear soon."];function Us(){return Kt[Math.floor(Math.random()*Kt.length)]??Kt[0]}function Vs(e){return ht(e,0,100)}function ht(e,t,i){return Number.isFinite(e)?Math.min(i,Math.max(t,e)):t}let C=class extends R{constructor(){super(...arguments),this.messages=[],this.sessionId="",this.messageStart=0,this.messageEnd=0,this.messageTotal=0,this.hasMore=!1,this.loadingMore=!1,this.isReceivingPartialStream=!1,this.isCompacting=!1,this.pendingMessageCount=0,this.pinnedToBottom=!0,this.disclosures=new Nd,this.scrollController=new lp,this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.groupedMessagesStart=0,this.groupedMessagesCache=[],this.messageMetaCache=new WeakMap,this.messageCopyTextCache=new WeakMap,this.lastScrollTop=0,this.lastClientHeight=0,this.prependRestoreToken=0,this.loadMoreRequested=!1,this.onViewportResize=()=>{this.pinnedToBottom?this.scrollToBottom():this.lastClientHeight=this.chat?.clientHeight??0},this.onPageHide=()=>{this.saveScrollPosition()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.onViewportResize),window.addEventListener("pagehide",this.onPageHide),window.visualViewport?.addEventListener("resize",this.onViewportResize)}firstUpdated(){this.lastClientHeight=this.chat?.clientHeight??0}disconnectedCallback(){this.saveScrollPosition(),this.scrollController.dispose(),this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.loadMoreCheckFrame!==void 0&&cancelAnimationFrame(this.loadMoreCheckFrame),this.scrollToBottomFrame!==void 0&&cancelAnimationFrame(this.scrollToBottomFrame),this.conversationRailFrame!==void 0&&cancelAnimationFrame(this.conversationRailFrame),window.removeEventListener("resize",this.onViewportResize),window.removeEventListener("pagehide",this.onPageHide),window.visualViewport?.removeEventListener("resize",this.onViewportResize),super.disconnectedCallback()}savePreviousSessionScrollPosition(e){typeof e!="string"||e===""||e===this.sessionId||this.saveScrollPosition(e)}prepareSessionUiState(){this.disclosures.syncSession(this.sessionId),this.scrollController.clearScheduledSave(),this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1,this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0,this.prependRestoreToken+=1,this.restoreScrollFrame!==void 0&&(cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=void 0)}willUpdate(e){e.has("sessionId")&&(this.savePreviousSessionScrollPosition(e.get("sessionId")),this.prepareSessionUiState()),(e.has("isReceivingPartialStream")||e.has("sessionId")&&this.isReceivingPartialStream)&&this.syncPartialStreamNoticeBody(),e.has("messages")&&(this.pinnedToBottom=this.pinnedToBottom&&(this.didChatHeightChange()||this.isNearBottom()))}update(e){const t=this.isPrependingMessages(e)?this.capturePrependScrollAnchor():void 0;super.update(e),t!==void 0&&this.restorePrependScrollAnchor(t)}updated(e){e.has("loadingMore")&&!this.loadingMore&&(this.loadMoreRequested=!1),e.has("hasMore")&&!this.hasMore&&(this.loadMoreRequested=!1),e.has("sessionId")&&this.restoreScrollPosition(),!e.has("sessionId")&&e.has("messages")&&this.pinnedToBottom&&this.scrollToBottom(),(e.has("messages")||e.has("messageStart")||e.has("messageTotal")||e.has("hasMore")||e.has("loadingMore"))&&this.scheduleConversationRailUpdate(),(e.has("messages")||e.has("messageStart")||e.has("hasMore")||e.has("loadingMore"))&&this.continuePendingScrollRestore(),(e.has("messages")||e.has("hasMore")||e.has("loadingMore"))&&this.requestLoadMoreIfNeeded()}render(){const e=this.groupedMessages();return c`
|
|
807
|
+
<div class="chat-wrap">
|
|
808
|
+
${this.renderConversationRail()}
|
|
809
|
+
<div class="chat" @scroll=${()=>{this.onScroll()}} @wheel=${t=>{this.onWheel(t)}} @touchstart=${t=>{this.onTouchStart(t)}} @touchmove=${t=>{this.onTouchMove(t)}}>
|
|
810
|
+
${this.renderHistoryBoundary()}
|
|
811
|
+
${Od(e,t=>t.kind==="message"?this.messageAnchorKey(t.index):this.groupRenderKey(t.startIndex),(t,i)=>t.kind==="message"?this.renderMessage(t.message,t.index):this.renderMessageGroup(t.messages,t.startIndex,t.endIndex,this.isLiveTailGroup(e,i)))}
|
|
812
|
+
${this.renderQueuedMessages()}
|
|
813
|
+
${this.renderSessionActivity()}
|
|
814
|
+
</div>
|
|
815
|
+
${this.renderActivityDock()}
|
|
816
|
+
</div>
|
|
817
|
+
`}groupedMessages(){return this.groupedMessagesInput===this.messages&&this.groupedMessagesStart===this.messageStart?this.groupedMessagesCache:(this.groupedMessagesInput=this.messages,this.groupedMessagesStart=this.messageStart,this.groupedMessagesCache=zd(this.messages,this.messageStart),this.groupedMessagesCache)}isLiveTailGroup(e,t){return t===e.length-1&&this.isSessionLive()}isSessionLive(){return this.status?.isStreaming===!0||this.status?.isCompacting===!0||this.status?.isBashRunning===!0||this.activity?.phase==="active"}renderActivityDock(){const e=this.activityState();if(e===void 0)return null;const t=e!=="idle"||this.activity?.phase==="active";return c`
|
|
818
|
+
<div class=${t?"activity-dock active":"activity-dock"} aria-live="polite">
|
|
819
|
+
<span class="dot"></span>
|
|
820
|
+
<span class="activity-text">${this.activityText(e)}</span>
|
|
821
|
+
</div>
|
|
822
|
+
`}renderQueuedMessages(){const e=this.status?.queuedMessages??[];return e.length===0?null:c`
|
|
823
|
+
<aside class="queued-messages" aria-live="polite">
|
|
824
|
+
<div class="queued-header">
|
|
825
|
+
<strong>Queued messages</strong>
|
|
826
|
+
<small>${e.length} pending · Stop clears the queue</small>
|
|
827
|
+
</div>
|
|
828
|
+
${e.map((t,i)=>c`
|
|
829
|
+
<div class="queued-message">
|
|
830
|
+
<span class="queued-kind">${t.kind==="steer"?"Steer":"Follow-up"} ${String(i+1)}</span>
|
|
831
|
+
<formatted-text .text=${t.text}></formatted-text>
|
|
832
|
+
</div>
|
|
833
|
+
`)}
|
|
834
|
+
</aside>
|
|
835
|
+
`}renderSessionActivity(){return this.isReceivingPartialStream?c`
|
|
836
|
+
<aside class="session-activity receiving" aria-live="polite">
|
|
837
|
+
<strong>Catching up…</strong>
|
|
838
|
+
<span>${this.currentPartialStreamNoticeBody()}</span>
|
|
839
|
+
</aside>
|
|
840
|
+
`:this.isCompacting?c`
|
|
841
|
+
<aside class="session-activity compacting" aria-live="polite">
|
|
842
|
+
<strong>Compacting history…</strong>
|
|
843
|
+
<span>The agent is summarizing earlier context. New prompts will be queued until compaction finishes.</span>
|
|
844
|
+
${this.pendingMessageCount>0?c`<small>${this.pendingMessageCount} queued ${this.pendingMessageCount===1?"message":"messages"}</small>`:null}
|
|
845
|
+
</aside>
|
|
846
|
+
`:null}syncPartialStreamNoticeBody(){this.partialStreamNoticeBody=this.isReceivingPartialStream?Us():void 0}currentPartialStreamNoticeBody(){return this.partialStreamNoticeBody??=Us(),this.partialStreamNoticeBody}activityState(){const e=this.status;return e===void 0?this.activity?.label:e.isCompacting?"compacting":e.isBashRunning?"bash":e.isStreaming?"running":e.pendingMessageCount>0?"queued":"idle"}activityText(e){const t=this.activity;return t===void 0||e!=="idle"&&t.phase==="idle"?e:t.detail!==void 0&&t.detail!==""?`${t.label}: ${t.detail}`:t.label}renderConversationRail(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.conversationDisplayTotal(),t=this.conversationPositionPercent(e),i=this.hasMore?Vs(this.messages.length/e*100):100;return c`<conversation-meter .positionPercent=${t} .loadedPercent=${i}></conversation-meter>`}conversationDisplayTotal(){return!this.hasMore&&this.messageStart===0?Math.max(1,this.messages.length):Math.max(1,this.messageTotal,this.messageStart+this.messages.length)}conversationPositionPercent(e=this.conversationDisplayTotal()){if(e<=1)return 100;const t=this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,i=ht(this.currentConversationIndex??t,0,e-1);return Vs(i/(e-1)*100)}renderHistoryBoundary(){const e=this.historyRangeLabel();return this.loadingMore?c`<div class="history-boundary"><span>Loading earlier messages…</span>${e}</div>`:this.hasMore?c`
|
|
847
|
+
<div class="history-boundary">
|
|
848
|
+
<button type="button" class="history-load-button" ?disabled=${this.loadMoreRequested} @click=${()=>{this.requestLoadMore()}}>Load earlier messages</button>
|
|
849
|
+
<span>Scroll up to load earlier messages</span>
|
|
850
|
+
${e}
|
|
851
|
+
</div>
|
|
852
|
+
`:this.messages.length?c`<div class="history-boundary"><span>Beginning of session</span>${e}</div>`:null}historyRangeLabel(){if(!this.messages.length||this.messageTotal<=0)return null;const e=this.messageStart+1,t=this.loadedRawMessageEnd(),i=Math.max(this.messageTotal,t);return c`<small>Showing messages ${e}–${t} of ${i}</small>`}loadedRawMessageEnd(){return Math.max(this.messageEnd,this.messageStart+this.messages.length)}renderMessage(e,t){const i=this.isToolExecutionOnlyMessage(e);return c`
|
|
853
|
+
${this.renderScrollMarker(this.messageScrollMarkerId(t))}
|
|
854
|
+
<article class=${i?"msg tool-execution-shell":`msg ${e.role}`} data-index=${t} data-scroll-anchor-id=${this.messageAnchorKey(t)}>
|
|
855
|
+
${i?null:this.renderMessageHeader(e,String(t))}
|
|
856
|
+
${e.parts.map(s=>this.renderPart(s,e))}
|
|
857
|
+
</article>
|
|
858
|
+
`}isToolExecutionOnlyMessage(e){return e.role==="tool"&&e.parts.length>0&&e.parts.every(t=>t.type==="toolExecution")}renderMessageGroup(e,t,i,s){const r=this.groupDisclosureKey(t,i,s),o=this.disclosures.isOpen(r,s);return c`
|
|
859
|
+
${this.renderScrollMarker(this.groupScrollMarkerId(i))}
|
|
860
|
+
<details class=${s?"msg event-group live":"msg event-group"} data-index=${t} data-scroll-anchor-id=${this.groupAnchorKey(t)} ?open=${o} @toggle=${n=>{this.onGroupToggle(r,n,s)}}>
|
|
861
|
+
<summary>
|
|
862
|
+
<b class="label">${s?"live events":"events"}</b>
|
|
863
|
+
<span>${qd(e)}</span>
|
|
864
|
+
</summary>
|
|
865
|
+
<div class="group-body">
|
|
866
|
+
${e.map((n,a)=>{const l=this.isToolExecutionOnlyMessage(n);return c`
|
|
867
|
+
<section class=${l?"group-msg tool-execution-shell":`group-msg ${n.role}`} data-index=${t+a} data-scroll-anchor-id=${this.eventAnchorKey(t+a)}>
|
|
868
|
+
${l?null:this.renderMessageHeader(n,`${String(t)}:${String(a)}`)}
|
|
869
|
+
${n.parts.map(d=>this.renderPart(d,n))}
|
|
870
|
+
</section>
|
|
871
|
+
`})}
|
|
872
|
+
</div>
|
|
873
|
+
</details>
|
|
874
|
+
`}renderScrollMarker(e){return c`<span class="scroll-marker" data-marker-id=${e} aria-hidden="true"></span>`}renderMessageHeader(e,t){const i=this.messageMetaLabel(e),s=this.expandedMetaKey===t;return c`
|
|
875
|
+
<div class="msg-header">
|
|
876
|
+
<b class="label">${e.role}</b>
|
|
877
|
+
<div class="msg-header-trailing">
|
|
878
|
+
${this.renderMessageActions(e,t)}
|
|
879
|
+
<span class=${s?"msg-meta expanded":"msg-meta"} role="button" tabindex="0" title=${i.full} aria-label=${i.full} aria-expanded=${String(s)} @click=${()=>{this.expandedMetaKey=s?void 0:t}} @keydown=${r=>{this.onMetaKeydown(r,t,s)}}>${i.short}</span>
|
|
880
|
+
</div>
|
|
881
|
+
</div>
|
|
882
|
+
`}renderMessageActions(e,t){if(!this.isCopyableMessage(e))return null;const i=this.copiedMessageKey===t;return c`
|
|
883
|
+
<div class="msg-actions" aria-label="Message actions">
|
|
884
|
+
<button type="button" class="msg-action" title=${i?"Copied":"Copy message"} aria-label=${`${i?"Copied":"Copy"} ${e.role} message`} @click=${s=>{this.copyMessage(e,t,s)}}>
|
|
885
|
+
<span aria-hidden="true">${i?"✓":"⧉"}</span>
|
|
886
|
+
</button>
|
|
887
|
+
</div>
|
|
888
|
+
`}onMetaKeydown(e,t,i){e.key!=="Enter"&&e.key!==" "||(e.preventDefault(),this.expandedMetaKey=i?void 0:t)}isCopyableMessage(e){return(e.role==="user"||e.role==="assistant")&&this.messageCopyText(e)!==""}messageCopyText(e){const t=this.messageCopyTextCache.get(e);if(t!==void 0)return t;const i=e.parts.filter(s=>s.type==="text").map(s=>s.text.trim()).filter(s=>s!=="").join(`
|
|
889
|
+
|
|
890
|
+
`);return this.messageCopyTextCache.set(e,i),i}async copyMessage(e,t,i){i.stopPropagation(),await this.writeClipboard(this.messageCopyText(e))&&(this.copiedMessageKey=t,window.setTimeout(()=>{this.copiedMessageKey===t&&(this.copiedMessageKey=void 0)},1200))}async writeClipboard(e){try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}messageMetaLabel(e){const t=this.messageMetaCache.get(e);if(t!==void 0)return t;const i=e.meta?.timestamp,s=this.modelLabel(e);if(i===void 0&&s===void 0){const l={short:"no info",full:"No Pi message metadata available"};return this.messageMetaCache.set(e,l),l}const r=i===void 0?void 0:this.formatTimestamp(i),o=[r?.short,s].filter(l=>l!==void 0&&l!==""),n=[r?.full,s===void 0?void 0:`Model: ${s}`].filter(l=>l!==void 0&&l!==""),a={short:o.join(" · "),full:n.join(" · ")};return this.messageMetaCache.set(e,a),a}formatTimestamp(e){const t=new Date(e);if(Number.isFinite(t.getTime()))return{short:Ph.format(t),full:Th.format(t)}}modelLabel(e){const t=e.meta?.model;if(t===void 0)return;const i=t.responseId??t.id;return i===void 0||i===""?t.provider:t.provider!==void 0&&t.provider!==""?`${t.provider}/${i}`:i}renderPart(e,t){return e.type==="text"&&t?.role==="bash"?c`<pre class="part shell-output">${e.text}</pre>`:e.type==="text"?c`<formatted-text class="part" .text=${e.text}></formatted-text>`:e.type==="thinking"?c`<details class="part"><summary>thinking</summary><formatted-text .text=${e.text}></formatted-text></details>`:e.type==="skillInvocation"?c`
|
|
891
|
+
<details class="part skill-invocation">
|
|
892
|
+
<summary><b>[skill]</b> ${e.name}</summary>
|
|
893
|
+
<small>${e.location}</small>
|
|
894
|
+
<formatted-text .text=${e.content}></formatted-text>
|
|
895
|
+
</details>
|
|
896
|
+
`:e.type==="skillRead"?c`
|
|
897
|
+
<div class="part skill-read">
|
|
898
|
+
<strong>Loaded ${e.name}</strong>
|
|
899
|
+
<small>read ${e.path}</small>
|
|
900
|
+
</div>
|
|
901
|
+
`:e.type==="toolCall"?c`<div class="part tool-line">▶ ${e.toolName}<span class="summary">${e.summary}</span></div>`:e.type==="toolExecution"?c`<tool-execution-view class="part" .execution=${e}></tool-execution-view>`:e.type==="toolResult"?c`
|
|
902
|
+
<details class="part" ?open=${e.isError}>
|
|
903
|
+
<summary>${e.isError?"✖":"✓"} ${e.toolName} result</summary>
|
|
904
|
+
<formatted-text .text=${e.text}></formatted-text>
|
|
905
|
+
</details>
|
|
906
|
+
`:null}onGroupToggle(e,t,i){const s=t.currentTarget;s instanceof HTMLDetailsElement&&this.disclosures.applyToggle(e,s.open,i)&&this.requestUpdate()}onScroll(){this.requestLoadMoreIfNeeded(),this.updatePinnedToBottomFromScroll(),this.scheduleConversationRailUpdate(),this.suppressScrollSave||this.scheduleScrollPositionSave()}onWheel(e){e.deltaY<0&&this.canScrollUp()&&(this.pinnedToBottom=!1)}onTouchStart(e){this.touchStartY=e.touches[0]?.clientY}onTouchMove(e){const t=e.touches[0]?.clientY;this.touchStartY!==void 0&&t!==void 0&&t>this.touchStartY&&this.canScrollUp()&&(this.pinnedToBottom=!1)}updatePinnedToBottomFromScroll(){const e=this.chat;if(!e)return;const t=this.didChatHeightChange(),i=this.pinnedToBottom,s=e.scrollTop<this.lastScrollTop;if(t&&i){this.lastClientHeight=e.clientHeight,this.scrollToBottom();return}this.isAtBottom()?this.pinnedToBottom=!0:s?this.pinnedToBottom=!1:this.pinnedToBottom=this.isNearBottom(),this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight}didChatHeightChange(){const e=this.chat;return e!==void 0&&this.lastClientHeight!==0&&e.clientHeight!==this.lastClientHeight}isPrependingMessages(e){const t=e.get("messageStart");return typeof t=="number"&&this.messageStart<t}requestLoadMoreIfNeeded(){this.loadMoreCheckFrame===void 0&&(this.loadMoreCheckFrame=requestAnimationFrame(()=>{if(this.loadMoreCheckFrame=void 0,this.suppressLoadMoreRequests)return;const e=this.chat;e&&Yd({hasMore:this.hasMore,loadingMore:this.loadingMore||this.loadMoreRequested,canRequest:this.onLoadMore!==void 0,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight})&&this.requestLoadMore()}))}requestLoadMore(){this.loadMoreRequested||!this.hasMore||this.loadingMore||this.onLoadMore===void 0||(this.loadMoreRequested=!0,this.onLoadMore())}isNearBottom(){const e=this.chat;return e?Br(e):!0}isAtBottom(){const e=this.chat;return e?Fr(e)<2:!0}canScrollUp(){const e=this.chat;return e!==void 0&&e.scrollTop>0}scrollToBottom(){this.scrollToBottomFrame===void 0&&(this.scrollToBottomFrame=requestAnimationFrame(()=>{this.scrollToBottomFrame=void 0;const e=this.chat;e&&this.withSuppressedScrollSave(()=>{e.scrollTop=e.scrollHeight,this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight})}))}restoreScrollPosition(){const e=this.sessionId;this.restoreScrollFrame!==void 0&&cancelAnimationFrame(this.restoreScrollFrame),this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const t=this.scrollController.restorePosition(e,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,t)})})}continuePendingScrollRestore(){const e=this.pendingScrollRestoreSessionId,t=this.pendingScrollRestorePosition;e===void 0||t===void 0||e!==this.sessionId||this.restoreScrollFrame!==void 0||(this.restoreScrollFrame=requestAnimationFrame(()=>{this.restoreScrollFrame=void 0,this.sessionId===e&&this.withSuppressedScrollSave(()=>{const i=this.scrollController.restoreExplicitPosition(t,this.chat,this.scrollAnchorElements(),{fallbackToBottom:this.shouldFallbackToBottomForMissingAnchor()});this.handleScrollRestoreResult(e,i)})}))}handleScrollRestoreResult(e,t){if(this.syncScrollMetrics(),t.status!=="missing"){this.updatePinnedToBottomAfterRestore(t.status),(t.status==="restored"||t.status==="bottom")&&this.cancelPrependRestore(),this.pendingScrollRestoreSessionId=void 0,this.pendingScrollRestorePosition=void 0;return}this.pinnedToBottom=!1,this.pendingScrollRestoreSessionId=e,this.pendingScrollRestorePosition=t.position;const i=this.chat;i===void 0||!this.hasMore||this.loadingMore||(i.scrollTop=0,this.syncScrollMetrics(),this.requestLoadMore())}shouldFallbackToBottomForMissingAnchor(){return!this.hasMore&&!this.isReceivingPartialStream}updatePinnedToBottomAfterRestore(e){e==="bottom"?this.pinnedToBottom=!0:e==="restored"&&(this.pinnedToBottom=this.isNearBottom())}syncScrollMetrics(){const e=this.chat;e!==void 0&&(this.lastScrollTop=e.scrollTop,this.lastClientHeight=e.clientHeight)}cancelPrependRestore(){this.prependRestoreToken+=1,this.suppressLoadMoreRequests=!1}capturePrependScrollAnchor(){const e=this.chat;if(e)return Ud(e,this.scrollMarkers())}restorePrependScrollAnchor(e){if(!this.chat||!e)return;this.suppressLoadMoreRequests=!0,this.suppressScrollSave=!0;const t=this.prependRestoreToken+1;this.prependRestoreToken=t;let i=0;const s=()=>{const r=this.chat;if(!(!r||t!==this.prependRestoreToken)){if(Vd(r,e,e.markerId===void 0?void 0:this.scrollMarkerAt(e.markerId)),this.lastScrollTop=r.scrollTop,i+=1,i<Hd){requestAnimationFrame(s);return}requestAnimationFrame(()=>{t===this.prependRestoreToken&&(this.suppressScrollSave=!1,this.suppressLoadMoreRequests=!1)})}};s()}saveScrollPosition(e=this.sessionId){e&&this.scrollController.savePosition(e,this.chat,this.scrollAnchorElements())}scheduleScrollPositionSave(){const e=this.sessionId;this.scrollController.scheduleSave(e,t=>{this.sessionId===t&&this.saveScrollPosition(t)})}scheduleConversationRailUpdate(){this.conversationRailFrame===void 0&&(this.conversationRailFrame=requestAnimationFrame(()=>{this.conversationRailFrame=void 0,this.updateConversationRailPosition()}))}updateConversationRailPosition(){if(!this.messages.length||this.messageTotal<=0){this.currentConversationIndex=void 0;return}const e=this.conversationDisplayTotal(),t=this.firstVisibleArticle(),i=Number(t?.dataset.index);if(Number.isFinite(i)){this.currentConversationIndex=ht(i,0,Math.max(0,e-1));return}this.currentConversationIndex=ht(this.pinnedToBottom?this.messageStart+this.messages.length-1:this.messageStart,0,Math.max(0,e-1))}scrollMarkers(){return Array.from(this.renderRoot.querySelectorAll(".scroll-marker"))}scrollMarkerAt(e){return this.scrollMarkers().find(t=>t.dataset.markerId===e)}firstVisibleArticle(){const e=this.chat;if(e===void 0)return;const t=Array.from(this.renderRoot.querySelectorAll("article.msg"));return _s(e,t)??_s(e,this.articles())}articles(){return Array.from(this.renderRoot.querySelectorAll("article.msg, details.msg"))}scrollAnchorElements(){return Array.from(this.renderRoot.querySelectorAll("[data-scroll-anchor-id]"))}withSuppressedScrollSave(e){this.suppressScrollSave=!0,e(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.suppressScrollSave=!1})})}groupDisclosureKey(e,t,i){return i?`${this.sessionId}:live:${String(e)}`:`${this.sessionId}:${String(t)}`}messageAnchorKey(e){return`m:${String(e)}`}groupRenderKey(e){return`g:${String(e)}`}groupAnchorKey(e){return`g:${String(e)}`}eventAnchorKey(e){return`e:${String(e)}`}messageScrollMarkerId(e){return`m:${String(e)}`}groupScrollMarkerId(e){return`g:${String(e)}`}};C.styles=ud;E([h({attribute:!1})],C.prototype,"messages",2);E([h()],C.prototype,"sessionId",2);E([h({type:Number})],C.prototype,"messageStart",2);E([h({type:Number})],C.prototype,"messageEnd",2);E([h({type:Number})],C.prototype,"messageTotal",2);E([h({type:Boolean})],C.prototype,"hasMore",2);E([h({type:Boolean})],C.prototype,"loadingMore",2);E([h({type:Boolean})],C.prototype,"isReceivingPartialStream",2);E([h({type:Boolean})],C.prototype,"isCompacting",2);E([h({type:Number})],C.prototype,"pendingMessageCount",2);E([h({attribute:!1})],C.prototype,"status",2);E([h({attribute:!1})],C.prototype,"activity",2);E([h({attribute:!1})],C.prototype,"onLoadMore",2);E([se(".chat")],C.prototype,"chat",2);E([x()],C.prototype,"pinnedToBottom",2);E([x()],C.prototype,"expandedMetaKey",2);E([x()],C.prototype,"copiedMessageKey",2);E([x()],C.prototype,"currentConversationIndex",2);E([x()],C.prototype,"loadMoreRequested",2);C=E([F("chat-view")],C);class Ch extends Ri{constructor(t){super(t),this.wasSelected=!1,this.isElementPart=t.type===Ii.ELEMENT}update(t,[i,s]){if(!this.isElementPart)throw new Error("scrollWhenSelected must be used on an element");if(i&&(!this.wasSelected||s!==this.previousKey)){const r="element"in t?t.element:void 0;requestAnimationFrame(()=>{r instanceof HTMLElement&&r.scrollIntoView({block:"nearest"})})}this.wasSelected=i,this.previousKey=s}render(t,i){}}const zi=Ai(Ch);var Ih=Object.defineProperty,Ah=Object.getOwnPropertyDescriptor,_t=(e,t,i,s)=>{for(var r=s>1?void 0:s?Ah(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Ih(t,i,r),r};let Re=class extends R{constructor(){super(...arguments),this.items=[],this.selectedIndex=0}render(){return this.items.length?c`
|
|
907
|
+
<div class="menu">
|
|
908
|
+
${this.items.map((e,t)=>c`
|
|
909
|
+
<button class=${t===this.selectedIndex?"selected":""} ${zi(t===this.selectedIndex,e)} @mousedown=${i=>{i.preventDefault(),this.onPick?.(e)}}>
|
|
910
|
+
<strong>${e.insertText}</strong>
|
|
911
|
+
<span>${e.detail}</span>
|
|
912
|
+
${e.description!==void 0&&e.description!==""?c`<small>${e.description}</small>`:null}
|
|
913
|
+
</button>
|
|
914
|
+
`)}
|
|
915
|
+
</div>
|
|
916
|
+
`:null}};Re.styles=gd;_t([h({attribute:!1})],Re.prototype,"items",2);_t([h({type:Number})],Re.prototype,"selectedIndex",2);_t([h({attribute:!1})],Re.prototype,"onPick",2);Re=_t([F("autocomplete-menu")],Re);var Rh=Object.defineProperty,Mh=Object.getOwnPropertyDescriptor,B=(e,t,i,s)=>{for(var r=s>1?void 0:s?Mh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Rh(t,i,r),r};let W=class extends R{constructor(){super(...arguments),this.disabled=!1,this.canSteer=!1,this.isCompacting=!1,this.canStop=!1,this.draft="",this.completions=[],this.selectedIndex=0,this.requestVersion=0,this.editableCompartment=new Hi,this.readOnlyCompartment=new Hi}willUpdate(e){if(!e.has("sessionId"))return;const t=e.get("sessionId");t!==void 0&&t!==""&&bt(t,this.draft),this.draft=this.sessionId!==void 0&&this.sessionId!==""?pr(this.sessionId):"",this.completions=[],this.selectedIndex=0}firstUpdated(){this.createEditor()}updated(e){e.has("disabled")&&this.updateEditorDisabledState(),(e.has("draft")||e.has("sessionId"))&&this.syncEditorDoc()}disconnectedCallback(){this.editor?.destroy(),this.editor=void 0,super.disconnectedCallback()}render(){const e=xi(this.draft),t=e.kind==="shell",i=this.canSteer||this.isCompacting;return c`
|
|
917
|
+
<footer class=${t?"shell-mode":""}>
|
|
918
|
+
<div class="editor-wrap">
|
|
919
|
+
<div class=${`markdown-editor${this.disabled?" markdown-editor-disabled":""}`} aria-label="Message pi" aria-disabled=${this.disabled?"true":"false"}></div>
|
|
920
|
+
${t?c`<div class="mode-hint">Shell command${e.excludeFromContext?" · excluded from context":""}</div>`:null}
|
|
921
|
+
${this.isCompacting&&!t?c`<div class="mode-hint">Compacting history · message will be queued</div>`:null}
|
|
922
|
+
<autocomplete-menu .items=${this.completions} .selectedIndex=${this.selectedIndex} .onPick=${s=>{this.pick(s)}}></autocomplete-menu>
|
|
923
|
+
</div>
|
|
924
|
+
<div class="actions">
|
|
925
|
+
${this.renderCompactStatus()}
|
|
926
|
+
<button ?disabled=${this.disabled} title=${i?"Queue until the current activity finishes":"Send message"} @click=${()=>{this.send("followUp")}}>${i?"Queue":"Send"}</button>
|
|
927
|
+
${this.canSteer&&!this.isCompacting?c`<button ?disabled=${this.disabled} title="Steer the current response before the next model call" @click=${()=>{this.send("steer")}}>Steer</button>`:null}
|
|
928
|
+
<button ?disabled=${this.disabled||!this.canStop} title=${this.canStop?"Stop current work and clear queued messages":"Nothing running"} @click=${()=>this.onStop?.()}>Stop</button>
|
|
929
|
+
</div>
|
|
930
|
+
</footer>
|
|
931
|
+
`}focusInput(){this.editor?.focus()}renderCompactStatus(){const e=this.status;if(e===void 0)return null;const t=e.model?.id??"no model",i=e.model?.provider!==void 0&&e.model.provider!==""?`${e.model.provider}/`:"";return c`
|
|
932
|
+
<div class="compact-status" aria-label="Session status">
|
|
933
|
+
<button class="select-model" title="Select model" @click=${()=>this.onSelectModel?.()}>${i}${t}</button>
|
|
934
|
+
<button class="select-thinking" title="Select thinking level" @click=${()=>this.onSelectThinking?.()}>think ${e.thinkingLevel??"off"}</button>
|
|
935
|
+
</div>
|
|
936
|
+
`}createEditor(){!this.editorHost||this.editor!==void 0||(this.editor=new Pe({parent:this.editorHost,state:Wt.create({doc:this.draft,extensions:[ro(),mo(),oo(),no.of(" "),ao(fo,{fallback:!0}),Pe.lineWrapping,Pe.contentAttributes.of(e=>Wh(e.state.sliceDoc(0,e.state.selection.main.head))),lo("Message pi... Use / for commands, @ for files"),this.editableCompartment.of(Pe.editable.of(!this.disabled)),this.readOnlyCompartment.of(Wt.readOnly.of(this.disabled)),Pe.updateListener.of(e=>{e.docChanged&&this.updateDraft(e.state.doc.toString())}),co.of([{key:"ArrowDown",run:()=>this.moveCompletion(1)},{key:"ArrowUp",run:()=>this.moveCompletion(-1)},{key:"Escape",run:()=>this.closeCompletions()},{key:"Enter",run:()=>this.handleEditorEnter()},{key:"Shift-Enter",run:e=>go(e)||uo(e)},{key:"Tab",run:e=>this.handleEditorTab(e)},{key:"Shift-Tab",run:e=>Ui.shift?.(e)??!1},{key:"Backspace",run:e=>vo(e)},...po,...ho])]})}))}syncEditorDoc(){const e=this.editor;if(!e)return;const t=e.state.doc.toString();t!==this.draft&&e.dispatch({changes:{from:0,to:t.length,insert:this.draft},selection:Vi.cursor(this.draft.length)})}updateEditorDisabledState(){this.editor?.dispatch({effects:[this.editableCompartment.reconfigure(Pe.editable.of(!this.disabled)),this.readOnlyCompartment.reconfigure(Wt.readOnly.of(this.disabled))]})}updateDraft(e){this.draft=e,this.sessionId!==void 0&&this.sessionId!==""&&bt(this.sessionId,this.draft),this.refreshCompletions()}async refreshCompletions(){const e=this.currentTrigger(),t=++this.requestVersion;if(this.selectedIndex=0,e===void 0){this.completions=[];return}if(e.kind==="command"&&this.sessionId!==void 0&&this.sessionId!==""){const i=await j.commands(this.sessionId).catch(Dh);if(t!==this.requestVersion)return;this.completions=i.filter(s=>s.name.toLowerCase().includes(e.query.toLowerCase())).slice(0,12).map(s=>({kind:"command",replaceFrom:e.from,replaceTo:e.to,insertText:`/${s.name}`,detail:s.source,...s.description===void 0?{}:{description:s.description}}))}else if(e.kind==="file"&&this.cwd!==void 0&&this.cwd!==""){const i=await j.files(this.cwd,e.query,e.fileKind,e.fileMode).catch(_h);if(t!==this.requestVersion)return;this.completions=i.slice(0,12).map(s=>{const r=Eh(s.path,e.fileMode==="path",e.quoted===!0);return{kind:"file",replaceFrom:e.from,replaceTo:e.to,insertText:r,detail:s.kind,...s.path.endsWith("/")&&r.endsWith('"')?{cursorOffset:r.length-1}:{}}})}}currentTrigger(){const e=this.editor?.state.selection.main.head??this.draft.length,t=this.draft.slice(0,e),i=this.currentQuotedTrigger(t,e);if(i!==void 0)return i;const s=Math.max(t.lastIndexOf(" "),t.lastIndexOf(`
|
|
937
|
+
`))+1,r=t.slice(s);if(t.slice(0,s).endsWith("@ "))return{kind:"file",query:r,from:s,to:e,fileMode:"path"};if(r.startsWith("/")&&s===0)return{kind:"command",query:r.slice(1),from:s,to:e};if(r.startsWith("@"))return{kind:"file",query:r.slice(1),from:s,to:e}}currentQuotedTrigger(e,t){const i=e.lastIndexOf('"');if(i===-1)return;const s=e.slice(0,i);if(s.endsWith("@"))return{kind:"file",query:e.slice(i+1),from:s.length-1,to:t,quoted:!0};if(s.endsWith("@ "))return{kind:"file",query:e.slice(i+1),from:i,to:t,fileMode:"path",quoted:!0}}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}handleEditorEnter(){if(this.completions.length){const e=this.completions[this.selectedIndex];return e!==void 0&&this.pick(e),!0}return this.send(this.canSteer||this.isCompacting?"followUp":void 0),!0}handleEditorTab(e){if(this.completions.length){const i=this.completions[this.selectedIndex];return i!==void 0&&this.pick(i),!0}return this.currentTrigger()?.kind==="file"?(this.refreshCompletions(),!0):Ui.run?.(e)??!1}pick(e){const t=this.editor;if(!t)return;const i=e.kind==="file"&&(e.insertText.endsWith("/")||e.cursorOffset!==void 0)?"":" ",s=e.replaceFrom+(e.cursorOffset??e.insertText.length)+i.length,r=e.insertText.endsWith('"')&&this.draft.slice(e.replaceTo).startsWith('"')?e.replaceTo+1:e.replaceTo;t.dispatch({changes:{from:e.replaceFrom,to:r,insert:`${e.insertText}${i}`},selection:Vi.cursor(s),scrollIntoView:!0}),this.completions=[]}send(e){const t=this.draft.trim();t===""||this.disabled||(this.draft="",this.sessionId!==void 0&&this.sessionId!==""&&yi(this.sessionId),this.completions=[],this.onSend?.(t,this.canSteer||this.isCompacting?e:void 0))}};W.styles=bd;B([h({type:Boolean})],W.prototype,"disabled",2);B([h()],W.prototype,"sessionId",2);B([h()],W.prototype,"cwd",2);B([h({type:Boolean})],W.prototype,"canSteer",2);B([h({type:Boolean})],W.prototype,"isCompacting",2);B([h({type:Boolean})],W.prototype,"canStop",2);B([h({attribute:!1})],W.prototype,"status",2);B([h({attribute:!1})],W.prototype,"onSend",2);B([h({attribute:!1})],W.prototype,"onStop",2);B([h({attribute:!1})],W.prototype,"onSelectModel",2);B([h({attribute:!1})],W.prototype,"onSelectThinking",2);B([se(".markdown-editor")],W.prototype,"editorHost",2);B([x()],W.prototype,"draft",2);B([x()],W.prototype,"completions",2);B([x()],W.prototype,"selectedIndex",2);W=B([F("prompt-editor")],W);function Eh(e,t,i){const s=t?"":"@";return!i&&!e.includes(" ")?`${s}${e}`:`${s}"${e}"`}function Dh(){return[]}function _h(){return[]}const Lh={spellcheck:"true",autocorrect:"on",autocapitalize:"sentences",writingsuggestions:"true"},Oh={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false"};function Wh(e){return xi(e).kind==="normal"?Lh:Oh}function nt(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 jh(e){return!Number.isFinite(e)||e===0?"$0":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}var Nh=Object.defineProperty,Fh=Object.getOwnPropertyDescriptor,Lt=(e,t,i,s)=>{for(var r=s>1?void 0:s?Fh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Nh(t,i,r),r};let Me=class extends R{constructor(){super(...arguments),this.workspaceLabelItems=[]}render(){const e=this.status;if(e===void 0)return c`<div class="bar muted">No session status yet</div>`;const t=e.contextUsage,i=t?t.percent==null?`context ${nt(t.contextWindow)}`:`${t.percent.toFixed(1)}%/${nt(t.contextWindow)}`:"context unknown",s=e.tokens;return c`
|
|
938
|
+
<div class="bar">
|
|
939
|
+
<span>${Wr(this.workspace?.label??"workspace",this.workspaceLabelItems,this.workspace?.path)}</span>
|
|
940
|
+
<span>↑${nt(s.input)}</span>
|
|
941
|
+
<span>↓${nt(s.output)}</span>
|
|
942
|
+
<span>${i}</span>
|
|
943
|
+
<span>${jh(e.cost)}</span>
|
|
944
|
+
${e.pendingMessageCount>0?c`<span>${String(e.pendingMessageCount)} queued</span>`:null}
|
|
945
|
+
</div>
|
|
946
|
+
`}};Me.styles=md;Lt([h({attribute:!1})],Me.prototype,"status",2);Lt([h({attribute:!1})],Me.prototype,"workspace",2);Lt([h({attribute:!1})],Me.prototype,"workspaceLabelItems",2);Me=Lt([F("status-bar")],Me);var Bh=Object.defineProperty,zh=Object.getOwnPropertyDescriptor,le=(e,t,i,s)=>{for(var r=s>1?void 0:s?zh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Bh(t,i,r),r};let te=class extends R{constructor(){super(...arguments),this.title="Select",this.searchable=!1,this.options=[],this.selectedIndex=0,this.query=""}render(){const e=this.filteredOptions();return c`
|
|
947
|
+
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
948
|
+
<section @mousedown=${t=>{t.stopPropagation()}}>
|
|
949
|
+
<header>
|
|
950
|
+
<strong>${this.title}</strong>
|
|
951
|
+
<button @click=${()=>this.onCancel?.()}>×</button>
|
|
952
|
+
</header>
|
|
953
|
+
${this.searchable?c`<input placeholder="Search" .value=${this.query} @input=${t=>{this.handleSearchInput(t)}} @keydown=${t=>{this.handleKeyDown(t)}}>`:null}
|
|
954
|
+
<div class="options" @keydown=${t=>{this.handleKeyDown(t)}} tabindex="0">
|
|
955
|
+
${e.map((t,i)=>c`
|
|
956
|
+
<button class=${i===this.selectedIndex?"selected":""} ${zi(i===this.selectedIndex,t.value)} @click=${()=>this.onPick?.(t.value)}>
|
|
957
|
+
<span>${t.label}</span>
|
|
958
|
+
${t.description!==void 0&&t.description!==""?c`<small>${t.description}</small>`:null}
|
|
959
|
+
</button>
|
|
960
|
+
`)}
|
|
961
|
+
${e.length===0?c`<div class="empty">No matching options</div>`:null}
|
|
962
|
+
</div>
|
|
963
|
+
</section>
|
|
964
|
+
</div>
|
|
965
|
+
`}firstUpdated(){this.selectInitialValue(),this.renderRoot.querySelector(this.searchable?"input":".options")?.focus()}selectInitialValue(){if(this.selectedValue===void 0)return;const e=this.filteredOptions().findIndex(t=>t.value===this.selectedValue);e>=0&&(this.selectedIndex=e)}handleSearchInput(e){e.target instanceof HTMLInputElement&&(this.query=e.target.value,this.selectedIndex=0)}filteredOptions(){const e=this.query.trim().toLowerCase();return e===""?this.options:this.options.filter(t=>`${t.label} ${t.description??""} ${t.value}`.toLowerCase().includes(e))}handleKeyDown(e){const t=this.filteredOptions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const i=t[this.selectedIndex];i&&this.onPick?.(i.value)}}};te.styles=Or;le([h()],te.prototype,"title",2);le([h({type:Boolean})],te.prototype,"searchable",2);le([h({attribute:!1})],te.prototype,"options",2);le([h({attribute:!1})],te.prototype,"selectedValue",2);le([h({attribute:!1})],te.prototype,"onPick",2);le([h({attribute:!1})],te.prototype,"onCancel",2);le([x()],te.prototype,"selectedIndex",2);le([x()],te.prototype,"query",2);te=le([F("command-picker")],te);var qh=Object.defineProperty,Hh=Object.getOwnPropertyDescriptor,Se=(e,t,i,s)=>{for(var r=s>1?void 0:s?Hh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&qh(t,i,r),r};let ae=class extends R{constructor(){super(...arguments),this.actions=[],this.queryText="",this.selectedIndex=0}render(){const e=this.filteredActions();return c`
|
|
966
|
+
<div class="backdrop" @mousedown=${()=>this.onCancel?.()}>
|
|
967
|
+
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
968
|
+
<header>
|
|
969
|
+
<input
|
|
970
|
+
.value=${this.queryText}
|
|
971
|
+
placeholder="Search actions..."
|
|
972
|
+
@input=${t=>{t.target instanceof HTMLInputElement&&(this.queryText=t.target.value,this.selectedIndex=0)}}
|
|
973
|
+
>
|
|
974
|
+
<button title="Close" @click=${()=>this.onCancel?.()}>×</button>
|
|
975
|
+
</header>
|
|
976
|
+
<div class="options">
|
|
977
|
+
${e.length===0?c`<div class="empty">No actions found.</div>`:e.map((t,i)=>c`
|
|
978
|
+
<button class=${i===this.selectedIndex?"selected":""} ${zi(i===this.selectedIndex,t.id)} @click=${()=>{this.run(t)}}>
|
|
979
|
+
<span class="main">
|
|
980
|
+
<strong>${t.title}</strong>
|
|
981
|
+
${t.description!==void 0&&t.description!==""?c`<small>${t.description}</small>`:null}
|
|
982
|
+
</span>
|
|
983
|
+
${t.shortcut!==void 0?c`<kbd>${ql(t.shortcut)}</kbd>`:null}
|
|
984
|
+
${t.group!==void 0&&t.group!==""?c`<small class="group">${t.group}</small>`:null}
|
|
985
|
+
</button>
|
|
986
|
+
`)}
|
|
987
|
+
</div>
|
|
988
|
+
</section>
|
|
989
|
+
</div>
|
|
990
|
+
`}firstUpdated(){this.input?.focus()}updated(e){if(!e.has("actions")&&!e.has("queryText"))return;const t=Math.max(0,this.filteredActions().length-1);this.selectedIndex>t&&(this.selectedIndex=t)}filteredActions(){const e=this.queryText.trim().toLowerCase();return this.actions.filter(t=>t.enabled!==!1).filter(t=>e===""?!0:[t.title,t.description??"",t.group??"",t.shortcut??""].join(" ").toLowerCase().includes(e))}handleKeyDown(e){const t=this.filteredActions();if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="ArrowDown")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex+1)%t.length);else if(e.key==="ArrowUp")e.preventDefault(),t.length>0&&(this.selectedIndex=(this.selectedIndex-1+t.length)%t.length);else if(e.key==="Enter"){e.preventDefault();const i=t[this.selectedIndex];i!==void 0&&this.run(i)}}run(e){this.onRun?.(e)}};ae.styles=vd;Se([h({attribute:!1})],ae.prototype,"actions",2);Se([h({attribute:!1})],ae.prototype,"onRun",2);Se([h({attribute:!1})],ae.prototype,"onCancel",2);Se([se("input")],ae.prototype,"input",2);Se([x()],ae.prototype,"queryText",2);Se([x()],ae.prototype,"selectedIndex",2);ae=Se([F("action-palette")],ae);var Uh=Object.defineProperty,Vh=Object.getOwnPropertyDescriptor,Z=(e,t,i,s)=>{for(var r=s>1?void 0:s?Vh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Uh(t,i,r),r};let H=class extends R{render(){const e=this.state;return e===void 0?null:c`
|
|
991
|
+
<div class="backdrop" @mousedown=${()=>{this.cancel()}}>
|
|
992
|
+
<section @mousedown=${t=>{t.stopPropagation()}} @keydown=${t=>{this.handleKeyDown(t)}}>
|
|
993
|
+
<header>
|
|
994
|
+
<strong>${this.dialogTitle(e)}</strong>
|
|
995
|
+
<button title="Close" @click=${()=>{this.cancel()}}>×</button>
|
|
996
|
+
</header>
|
|
997
|
+
${this.renderBody(e)}
|
|
998
|
+
</section>
|
|
999
|
+
</div>
|
|
1000
|
+
`}updated(){this.focusInputIfNeeded()}dialogTitle(e){switch(e.step){case"method":return"Configure provider authentication";case"providers":return e.authType===void 0?"Select provider authentication":e.authType==="oauth"?"Select subscription provider":"Select API key provider";case"apiKey":return`API key for ${e.provider.name}`;case"oauth":return`Login to ${e.flow.providerName}`;case"logout":return"Remove stored provider authentication"}}renderBody(e){switch(e.step){case"method":return c`
|
|
1001
|
+
<div class="options">
|
|
1002
|
+
<button @click=${()=>{this.onChooseMethod?.("oauth")}}><span>Use a subscription</span><small>ChatGPT Plus/Pro, Claude Pro/Max, or GitHub Copilot</small></button>
|
|
1003
|
+
<button @click=${()=>{this.onChooseMethod?.("api_key")}}><span>Use an API key</span><small>Store an API key in pi auth.json</small></button>
|
|
1004
|
+
</div>
|
|
1005
|
+
`;case"providers":return c`<div class="options">${e.providers.length===0?c`<div class="empty">No providers available.</div>`:e.providers.map(t=>this.renderProviderButton(t))}</div>`;case"apiKey":return c`
|
|
1006
|
+
<div class="form">
|
|
1007
|
+
<p>Enter the API key for <strong>${e.provider.name}</strong>. It will be stored by pi in <code>auth.json</code>.</p>
|
|
1008
|
+
<input type="password" autocomplete="off" placeholder="API key" .value=${e.value} @input=${t=>{t.target instanceof HTMLInputElement&&this.onApiKeyInput?.(t.target.value)}}>
|
|
1009
|
+
${e.error!==void 0&&e.error!==""?c`<div class="error-text">${e.error}</div>`:null}
|
|
1010
|
+
<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>
|
|
1011
|
+
</div>
|
|
1012
|
+
`;case"oauth":return this.renderOAuth(e);case"logout":return c`<div class="options">${e.providers.length===0?c`<div class="empty">No stored credentials. Environment variables and models.json settings are unchanged.</div>`:e.providers.map(t=>c`
|
|
1013
|
+
<button @click=${()=>{this.onLogoutProvider?.(t.id)}}><span>${t.name}</span><small>${t.id} · ${Gs(t.authType)}</small></button>
|
|
1014
|
+
`)}</div>`}}renderProviderButton(e){return c`
|
|
1015
|
+
<button @click=${()=>{this.onSelectProvider?.(e.id,e.authType)}}>
|
|
1016
|
+
<span>${e.name}${e.status.source!==void 0?c` <em>${Kh(e)}</em>`:null}</span>
|
|
1017
|
+
<small>${e.id} · ${Gs(e.authType)}</small>
|
|
1018
|
+
</button>
|
|
1019
|
+
`}renderOAuth(e){const t=e.flow,i=t.prompt,s=t.select;return c`
|
|
1020
|
+
<div class="form">
|
|
1021
|
+
${t.auth!==void 0?c`
|
|
1022
|
+
<p>Open this authorization link:</p>
|
|
1023
|
+
<p><a href=${t.auth.url} target="_blank" rel="noreferrer">${t.auth.url}</a></p>
|
|
1024
|
+
${t.auth.instructions!==void 0?c`<p class="warning">${t.auth.instructions}</p>`:null}
|
|
1025
|
+
`:c`<p>Starting login flow…</p>`}
|
|
1026
|
+
${t.progress.length>0?c`<ul class="progress">${t.progress.map(r=>c`<li>${r}</li>`)}</ul>`:null}
|
|
1027
|
+
${i!==void 0?c`
|
|
1028
|
+
<label>${i.message}</label>
|
|
1029
|
+
<input .value=${e.inputValue??""} placeholder=${i.placeholder??""} @input=${r=>{r.target instanceof HTMLInputElement&&this.onOAuthInput?.(r.target.value)}}>
|
|
1030
|
+
<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button><button class="primary" ?disabled=${e.responding===!0} @click=${()=>{this.onOAuthRespond?.()}}>Submit</button></div>
|
|
1031
|
+
`:null}
|
|
1032
|
+
${s!==void 0?c`
|
|
1033
|
+
<p>${s.message}</p>
|
|
1034
|
+
<div class="inline-options">${s.options.map(r=>c`<button @click=${()=>{this.onOAuthRespond?.(r.value)}}>${r.label}</button>`)}</div>
|
|
1035
|
+
`:null}
|
|
1036
|
+
${e.error!==void 0&&e.error!==""?c`<div class="error-text">${e.error}</div>`:null}
|
|
1037
|
+
${t.status==="error"||t.status==="cancelled"?c`<div class="error-text">${t.error??t.status}</div><div class="actions"><button @click=${()=>{this.cancel()}}>Close</button></div>`:null}
|
|
1038
|
+
${i===void 0&&s===void 0&&t.status==="running"?c`<div class="actions"><button @click=${()=>{this.onOAuthCancel?.()}}>Cancel</button></div>`:null}
|
|
1039
|
+
</div>
|
|
1040
|
+
`}focusInputIfNeeded(){const e=Gh(this.state);if(e===void 0){this.lastFocusedInputKey=void 0;return}e!==this.lastFocusedInputKey&&(this.lastFocusedInputKey=e,this.input?.focus())}handleKeyDown(e){if(e.key==="Escape"){e.preventDefault(),this.cancel();return}if(e.key!=="Enter")return;const t=this.state;t?.step==="apiKey"?(e.preventDefault(),this.onSaveApiKey?.()):t?.step==="oauth"&&t.flow.prompt!==void 0&&(e.preventDefault(),this.onOAuthRespond?.())}cancel(){this.state?.step==="oauth"?this.onOAuthCancel?.():this.onCancel?.()}};H.styles=[Or,V`
|
|
1041
|
+
.form { display: grid; gap: 12px; padding: 14px; overflow: auto; }
|
|
1042
|
+
.form p { margin: 0; color: var(--pi-text-secondary); overflow-wrap: anywhere; }
|
|
1043
|
+
.form a { color: var(--pi-accent); overflow-wrap: anywhere; }
|
|
1044
|
+
.form code { border: 1px solid var(--pi-border); border-radius: 4px; background: var(--pi-surface); padding: 1px 4px; }
|
|
1045
|
+
label { color: var(--pi-muted); }
|
|
1046
|
+
.actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
1047
|
+
.actions button, .inline-options button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; }
|
|
1048
|
+
.actions button.primary { border-color: var(--pi-success-border); background: var(--pi-success-surface); color: var(--pi-success); }
|
|
1049
|
+
.actions button:disabled { opacity: .6; cursor: wait; }
|
|
1050
|
+
.warning { color: var(--pi-warning); }
|
|
1051
|
+
.error-text { color: var(--pi-danger); }
|
|
1052
|
+
.progress { margin: 0; padding-left: 18px; color: var(--pi-muted); }
|
|
1053
|
+
.inline-options { display: grid; gap: 8px; }
|
|
1054
|
+
em { color: var(--pi-success); font-style: normal; font-size: 12px; }
|
|
1055
|
+
`];Z([h({attribute:!1})],H.prototype,"state",2);Z([h({attribute:!1})],H.prototype,"onChooseMethod",2);Z([h({attribute:!1})],H.prototype,"onSelectProvider",2);Z([h({attribute:!1})],H.prototype,"onApiKeyInput",2);Z([h({attribute:!1})],H.prototype,"onSaveApiKey",2);Z([h({attribute:!1})],H.prototype,"onLogoutProvider",2);Z([h({attribute:!1})],H.prototype,"onOAuthInput",2);Z([h({attribute:!1})],H.prototype,"onOAuthRespond",2);Z([h({attribute:!1})],H.prototype,"onOAuthCancel",2);Z([h({attribute:!1})],H.prototype,"onCancel",2);Z([se("input")],H.prototype,"input",2);H=Z([F("auth-dialog")],H);function Gs(e){return e==="oauth"?"subscription":"API key"}function Gh(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 Kh(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 Qh=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,ce=(e,t,i,s)=>{for(var r=s>1?void 0:s?Jh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Qh(t,i,r),r};let ie=class extends R{constructor(){super(...arguments),this.path="",this.createMissing=!0,this.suggestions=[],this.selected=0,this.loading=!1,this.requestId=0}connectedCallback(){super.connectedCallback(),this.loadSuggestions()}firstUpdated(){this.pathInput?.focus()}async loadSuggestions(){const e=++this.requestId;this.loading=!0;try{const t=await j.projectDirectories(this.path);if(e!==this.requestId)return;this.suggestions=t,this.selected=Math.min(this.selected,Math.max(0,t.length-1))}catch{e===this.requestId&&(this.suggestions=[])}finally{e===this.requestId&&(this.loading=!1)}}setPath(e){this.path=e,this.selected=0,this.loadSuggestions()}pick(e){this.setPath(e.path)}submit(){this.path.trim()!==""&&this.onSubmit?.(this.path,this.createMissing)}onPathInput(e){e.target instanceof HTMLInputElement&&this.setPath(e.target.value)}onCreateMissingChange(e){e.target instanceof HTMLInputElement&&(this.createMissing=e.target.checked)}onKeyDown(e){if(e.key==="Escape")e.preventDefault(),this.onCancel?.();else if(e.key==="Enter")e.preventDefault(),this.submit();else if(e.key==="ArrowDown")e.preventDefault(),this.selected=Math.min(this.selected+1,Math.max(0,this.suggestions.length-1));else if(e.key==="ArrowUp")e.preventDefault(),this.selected=Math.max(0,this.selected-1);else if(e.key==="Tab"){const t=this.suggestions[this.selected];if(t===void 0)return;e.preventDefault(),this.pick(t)}}render(){return c`
|
|
1056
|
+
<div class="backdrop" @click=${()=>this.onCancel?.()}>
|
|
1057
|
+
<section @click=${e=>{e.stopPropagation()}}>
|
|
1058
|
+
<header>
|
|
1059
|
+
<strong>Add project</strong>
|
|
1060
|
+
<button @click=${()=>{this.onCancel?.()}} aria-label="Close">×</button>
|
|
1061
|
+
</header>
|
|
1062
|
+
<div class="body">
|
|
1063
|
+
<label>
|
|
1064
|
+
Project folder
|
|
1065
|
+
<input .value=${this.path} @input=${e=>{this.onPathInput(e)}} @keydown=${e=>{this.onKeyDown(e)}} placeholder="/path/to/project or ~/code/project" autofocus />
|
|
1066
|
+
</label>
|
|
1067
|
+
<div class="suggestions">
|
|
1068
|
+
${this.loading?c`<div class="hint">Loading folders…</div>`:null}
|
|
1069
|
+
${this.suggestions.map((e,t)=>c`
|
|
1070
|
+
<button class=${t===this.selected?"selected":""} @click=${()=>{this.pick(e)}}>
|
|
1071
|
+
${e.path}
|
|
1072
|
+
</button>
|
|
1073
|
+
`)}
|
|
1074
|
+
${!this.loading&&this.suggestions.length===0?c`<div class="hint">No matching folders. Enter a new path to create it.</div>`:null}
|
|
1075
|
+
</div>
|
|
1076
|
+
<label class="check">
|
|
1077
|
+
<input type="checkbox" .checked=${this.createMissing} @change=${e=>{this.onCreateMissingChange(e)}} />
|
|
1078
|
+
Create the folder if it does not exist
|
|
1079
|
+
</label>
|
|
1080
|
+
</div>
|
|
1081
|
+
<footer>
|
|
1082
|
+
<button @click=${()=>{this.onCancel?.()}}>Cancel</button>
|
|
1083
|
+
<button class="primary" ?disabled=${this.path.trim()===""} @click=${()=>{this.submit()}}>Add project</button>
|
|
1084
|
+
</footer>
|
|
1085
|
+
</section>
|
|
1086
|
+
</div>
|
|
1087
|
+
`}};ie.styles=V`
|
|
1088
|
+
:host { position: fixed; inset: 0; z-index: 30; color: var(--pi-text); font: 14px system-ui, sans-serif; }
|
|
1089
|
+
.backdrop { display: grid; place-items: start center; width: 100%; height: 100%; padding-top: min(12vh, 90px); box-sizing: border-box; background: var(--pi-overlay); }
|
|
1090
|
+
section { width: min(720px, calc(100vw - 40px)); max-height: min(700px, calc(100vh - 40px)); display: flex; flex-direction: column; border: 1px solid var(--pi-border); border-radius: 12px; background: var(--pi-bg); box-shadow: 0 20px 60px var(--pi-shadow-strong); overflow: hidden; }
|
|
1091
|
+
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--pi-border); }
|
|
1092
|
+
footer { border-top: 1px solid var(--pi-border); border-bottom: 0; justify-content: end; }
|
|
1093
|
+
.body { display: grid; gap: 12px; padding: 12px; min-height: 0; }
|
|
1094
|
+
label { display: grid; gap: 6px; color: var(--pi-muted); }
|
|
1095
|
+
input[type="text"], input:not([type]) { box-sizing: border-box; width: 100%; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-bg); color: var(--pi-text); padding: 9px; font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1096
|
+
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; color: var(--pi-text); }
|
|
1097
|
+
.suggestions { min-height: 90px; max-height: 320px; overflow: auto; border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); }
|
|
1098
|
+
.suggestions button { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-bottom: 1px solid var(--pi-border); border-radius: 0; background: transparent; color: var(--pi-text); padding: 8px 10px; text-align: left; font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
|
1099
|
+
.suggestions button.selected, .suggestions button:hover { background: var(--pi-selection-bg); }
|
|
1100
|
+
.hint { padding: 12px; color: var(--pi-muted); }
|
|
1101
|
+
button { border: 1px solid var(--pi-border); border-radius: 8px; background: var(--pi-surface); color: var(--pi-text); padding: 7px 9px; cursor: pointer; }
|
|
1102
|
+
header button { border: 0; background: transparent; color: var(--pi-muted); font-size: 22px; padding: 0 8px; }
|
|
1103
|
+
.primary { border-color: var(--pi-success-border); background: var(--pi-success-border); }
|
|
1104
|
+
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
1105
|
+
`;ce([h({attribute:!1})],ie.prototype,"onSubmit",2);ce([h({attribute:!1})],ie.prototype,"onCancel",2);ce([x()],ie.prototype,"path",2);ce([x()],ie.prototype,"createMissing",2);ce([x()],ie.prototype,"suggestions",2);ce([x()],ie.prototype,"selected",2);ce([x()],ie.prototype,"loading",2);ce([se("input")],ie.prototype,"pathInput",2);ie=ce([F("project-dialog")],ie);var Zh=Object.defineProperty,Xh=Object.getOwnPropertyDescriptor,X=(e,t,i,s)=>{for(var r=s>1?void 0:s?Xh(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Zh(t,i,r),r};let U=class extends R{constructor(){super(...arguments),this.tool="core:workspace.files",this.panels=[],this.workspaceLabelItems=[],this.hideToolTabs=!1,this.onSelectTool=()=>{},this.workspaceHeaderCanScrollLeft=!1,this.workspaceHeaderCanScrollRight=!1,this.onWorkspaceHeaderScroll=()=>{this.updateWorkspaceHeaderScrollState()}}firstUpdated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}updated(){this.observeWorkspaceHeaderStrip(),this.updateWorkspaceHeaderScrollState()}disconnectedCallback(){this.workspaceHeaderResizeObserver?.disconnect(),this.workspaceHeaderResizeObserver=void 0,this.observedWorkspaceHeaderStrip=void 0,super.disconnectedCallback()}render(){const e=this.workspace;if(e===void 0)return this.renderEmptyState(this.emptyState??{title:"Select a workspace",body:"Choose a workspace to inspect files, Git, or terminals."});const t=this.panelContext;if(t===void 0)return this.renderEmptyState({title:"Workspace tools unavailable",body:"Try selecting the workspace again."});const i=this.panels,s=i.find(r=>r.id===this.tool)??i[0];return c`
|
|
1106
|
+
<header>
|
|
1107
|
+
<div class=${this.workspaceHeaderFrameClass()}>
|
|
1108
|
+
<div class="workspace-header-strip" @scroll=${this.onWorkspaceHeaderScroll}>
|
|
1109
|
+
${this.hideToolTabs?null:c`
|
|
1110
|
+
<div class="tabs">
|
|
1111
|
+
${i.map(r=>c`
|
|
1112
|
+
<button class=${s?.id===r.id?"selected":""} @click=${()=>{this.onSelectTool(r.id)}}>${this.renderPanelTitle(r,t)}</button>
|
|
1113
|
+
`)}
|
|
1114
|
+
</div>
|
|
1115
|
+
`}
|
|
1116
|
+
<small>${Wr(e.label,this.workspaceLabelItems,e.path)}</small>
|
|
1117
|
+
</div>
|
|
1118
|
+
</div>
|
|
1119
|
+
</header>
|
|
1120
|
+
${s===void 0?this.renderEmptyState({title:"No workspace tools available",body:"No tools are available for this workspace."}):c`
|
|
1121
|
+
<div class="panel-content">
|
|
1122
|
+
${s.render(t)}
|
|
1123
|
+
</div>
|
|
1124
|
+
`}
|
|
1125
|
+
`}renderPanelTitle(e,t){const i=e.badge?.(t);return i===void 0||i===""?c`${e.title}`:c`${e.title} <span class="tab-badge">${i}</span>`}renderEmptyState(e){return c`
|
|
1126
|
+
<section class="empty-state" role="status">
|
|
1127
|
+
<h2>${e.title}</h2>
|
|
1128
|
+
${e.body===void 0?null:c`<p>${e.body}</p>`}
|
|
1129
|
+
</section>
|
|
1130
|
+
`}workspaceHeaderFrameClass(){return`workspace-header-scroll-frame${this.workspaceHeaderCanScrollLeft?" can-scroll-left":""}${this.workspaceHeaderCanScrollRight?" can-scroll-right":""}`}observeWorkspaceHeaderStrip(){const e=this.workspaceHeaderStripElement();this.observedWorkspaceHeaderStrip!==e&&(this.workspaceHeaderResizeObserver?.disconnect(),this.observedWorkspaceHeaderStrip=e,this.workspaceHeaderResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.workspaceHeaderResizeObserver=new ResizeObserver(()=>{this.updateWorkspaceHeaderScrollState()}),this.workspaceHeaderResizeObserver.observe(e)))}updateWorkspaceHeaderScrollState(){const e=this.workspaceHeaderStripElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.workspaceHeaderCanScrollLeft!==i&&(this.workspaceHeaderCanScrollLeft=i),this.workspaceHeaderCanScrollRight!==s&&(this.workspaceHeaderCanScrollRight=s)}workspaceHeaderStripElement(){const e=this.workspaceHeaderStrip;return e instanceof HTMLElement?e:void 0}};U.styles=hd;X([h({attribute:!1})],U.prototype,"workspace",2);X([h({attribute:!1})],U.prototype,"panelContext",2);X([h({attribute:!1})],U.prototype,"emptyState",2);X([h()],U.prototype,"tool",2);X([h({attribute:!1})],U.prototype,"panels",2);X([h({attribute:!1})],U.prototype,"workspaceLabelItems",2);X([h({type:Boolean})],U.prototype,"hideToolTabs",2);X([h({attribute:!1})],U.prototype,"onSelectTool",2);X([se(".workspace-header-strip")],U.prototype,"workspaceHeaderStrip",2);X([x()],U.prototype,"workspaceHeaderCanScrollLeft",2);X([x()],U.prototype,"workspaceHeaderCanScrollRight",2);U=X([F("workspace-panel")],U);var Yh=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,D=(e,t,i,s)=>{for(var r=s>1?void 0:s?eu(t,i):t,o=e.length-1,n;o>=0;o--)(n=e[o])&&(r=(s?n(t,i,r):n(r))||r);return s&&r&&Yh(t,i,r),r};const tu=900*1e3,Ks={capture:!0},Qt="auto:on",Qs="auto:off",at="theme:",Js=Ke("core:workspace.terminal"),iu=550,su=250;let I=class extends R{constructor(){super(...arguments),this.state=Yn(),this.navigationPanelCollapsed=!1,this.workspacePanelCollapsed=!1,this.sessions=new Al(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.activity=new ea(()=>this.state,e=>{this.setState(e)}),this.auth=new sa(()=>this.state,e=>{this.setState(e)},e=>{this.sessions.applySessionStatus(e)}),this.workspaces=new Wl(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()},this.sessions),this.projects=new pa(()=>this.state,e=>{this.setState(e)},this.workspaces),this.files=new aa(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.git=new da(()=>this.state,e=>{this.setState(e)},()=>{this.updateUrl()}),this.keyboard=new zl,this.realtime=new wl,this.activeTerminalIds=new Set,this.terminalSelection=new Fl,this.mobileNavigationMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(max-width: 760px)"):void 0,this.systemLightThemeMedia=typeof window<"u"&&"matchMedia"in window?window.matchMedia("(prefers-color-scheme: light)"):void 0,this.pwaDisplayModeMedia=Vc(),this.refreshingWorkspaceDeletionRuns=!1,this.handledWorkspaceDeletionRunIds=new Set,this.terminalCommandRunRuntimes=new Map,this.routeRestoreInProgress=!1,this.plugins=ru(),this.themePreference=Zl()??Kl,this.suppressNextRefreshClick=!1,this.activeThemeId=Si,this.isMobileNavigationLayout=this.mobileNavigationMedia?.matches??!1,this.isPwaDisplayMode=Ps(this.pwaDisplayModeMedia),this.isRefreshingApp=!1,this.refreshMenuOpen=!1,this.refreshMenuStyle="",this.contextCanScrollLeft=!1,this.contextCanScrollRight=!1,this.mobileTabsCanScrollLeft=!1,this.mobileTabsCanScrollRight=!1,this.onPopState=()=>{this.withChatScrollTransition(()=>this.restoreRoute(!1))},this.onPageShow=()=>{this.repairViewportPosition()},this.onFocus=()=>{this.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns()},this.onVisibilityChange=()=>{document.visibilityState==="visible"&&(this.repairViewportPosition(),this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns())},this.onMobileNavigationMediaChange=e=>{this.isMobileNavigationLayout=e.matches,this.updateContextScrollState(),this.updateMobileTabsScrollState()},this.onSystemLightThemeChange=()=>{this.themePreference.auto&&this.applyPreferredTheme(!1)},this.onPwaDisplayModeChange=()=>{this.isPwaDisplayMode=Ps(this.pwaDisplayModeMedia)},this.onContextScroll=()=>{this.updateContextScrollState()},this.onMobileTabsScroll=()=>{this.updateMobileTabsScrollState()},this.onDocumentClick=e=>{const t=this.appRefreshElement();t!==void 0&&e.composedPath().includes(t)||(this.refreshMenuOpen=!1,this.suppressNextRefreshClick=!1)},this.onKeyDown=e=>{if(e.key==="Escape"&&this.refreshMenuOpen){e.preventDefault(),e.stopPropagation(),this.refreshMenuOpen=!1,this.suppressNextRefreshClick=!1;return}this.keyboard.handle(e,this.getActions())&&(e.preventDefault(),e.stopPropagation())}}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this.onPopState),window.addEventListener("pageshow",this.onPageShow),window.addEventListener("focus",this.onFocus),document.addEventListener("click",this.onDocumentClick),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("keydown",this.onKeyDown,Ks),this.mobileNavigationMedia?.addEventListener("change",this.onMobileNavigationMediaChange),this.systemLightThemeMedia?.addEventListener("change",this.onSystemLightThemeChange);for(const e of this.pwaDisplayModeMedia)e.addEventListener("change",this.onPwaDisplayModeChange);this.applyPreferredTheme(!1),this.connectRealtime(),this.piWebStatusTimer=window.setInterval(()=>{this.refreshPiWebStatus()},tu),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.loadExternalPlugins(),this.loadProjectsAndRestoreRoute()}disconnectedCallback(){window.removeEventListener("popstate",this.onPopState),window.removeEventListener("pageshow",this.onPageShow),window.removeEventListener("focus",this.onFocus),document.removeEventListener("click",this.onDocumentClick),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("keydown",this.onKeyDown,Ks),this.mobileNavigationMedia?.removeEventListener("change",this.onMobileNavigationMediaChange),this.systemLightThemeMedia?.removeEventListener("change",this.onSystemLightThemeChange);for(const e of this.pwaDisplayModeMedia)e.removeEventListener("change",this.onPwaDisplayModeChange);this.keyboard.reset(),this.auth.dispose(),this.sessions.dispose(),this.realtime.close(),this.git.dispose(),this.piWebStatusTimer!==void 0&&window.clearInterval(this.piWebStatusTimer),this.piWebStatusTimer=void 0,this.workspaceDeletionPollTimer!==void 0&&window.clearInterval(this.workspaceDeletionPollTimer),this.workspaceDeletionPollTimer=void 0,this.contextItemsResizeObserver?.disconnect(),this.contextItemsResizeObserver=void 0,this.observedContextItems=void 0,this.mobileTabsResizeObserver?.disconnect(),this.mobileTabsResizeObserver=void 0,this.observedMobileTabs=void 0,this.clearRefreshLongPressTimer(),this.clearViewportPositionRepair(),super.disconnectedCallback()}firstUpdated(){this.observeContextItems(),this.observeMobileTabs(),this.updateContextScrollState(),this.updateMobileTabsScrollState()}updated(){this.observeContextItems(),this.observeMobileTabs(),this.updateContextScrollState(),this.updateMobileTabsScrollState()}setState(e){if(!pu(this.state,e))return;const t=this.state;this.state={...this.state,...e},this.handleActivityTransition(t,this.state),this.handleWorkspaceChange(t,this.state)}async loadProjectsAndRestoreRoute(){await this.projects.loadProjects(),await this.withChatScrollTransition(()=>this.restoreRoute(!1)),await this.refreshWorkspaceDeletionRuns()}async refreshPiWebStatus(){try{this.setState({piWebStatus:await lr.piWebStatus()})}catch(e){console.warn("Failed to refresh PI WEB status",e)}}async refreshWorkspaceActivity(){try{await this.activity.refresh()}catch(e){console.warn("Failed to refresh workspace activity",e)}}async refreshAppData(){if(!this.isRefreshingApp){this.refreshMenuOpen=!1,this.suppressNextRefreshClick=!1,this.isRefreshingApp=!0;try{await Promise.all([this.sessions.refreshSelectedSession(),this.refreshPiWebStatus(),this.refreshWorkspaceActivity(),this.refreshWorkspaceDeletionRuns(),this.refreshCurrentWorkspaceSurface()])}finally{this.isRefreshingApp=!1}}}async refreshCurrentWorkspaceSurface(){const e=this.state.selectedWorkspace,t=this.state.mainView!=="chat"&&this.state.mainView!=="navigation"?this.state.mainView:this.state.workspaceTool;t==="core:workspace.files"?await this.files.refreshFiles():t==="core:workspace.git"?await this.git.refreshGit():t==="core:workspace.terminal"&&e!==void 0&&await this.refreshActiveTerminals(e)}hardReloadApp(){window.location.reload()}async restoreRoute(e){const t=Qc(),i=Bt(Ke("core:workspace.files"),"file"),s=Bt(Ke("core:workspace.git"),"diff"),r=Bt(Js,"terminal");this.routeRestoreInProgress=!0,this.restoringRouteTerminalId=r;try{if(this.setState({workspaceTool:t.tool??this.state.workspaceTool,mainView:t.view??this.defaultRouteView(),selectedFilePath:i,selectedDiffPath:s,selectedTerminalId:r}),t.projectId===void 0||t.projectId==="")return;if(this.routeMatchesCurrentSelection(t)){r!==void 0&&this.rememberSelectedTerminal(r),await this.refreshRestoredWorkspaceTool(t.tool,i),this.git.updatePolling();return}const o=this.state.projects.find(n=>n.id===t.projectId);if(!o)return;await this.workspaces.selectProject(o,{workspaceId:t.workspaceId,sessionId:t.sessionId,updateUrl:e}),this.setState({selectedFilePath:i,selectedDiffPath:s,selectedTerminalId:r}),r!==void 0&&this.rememberSelectedTerminal(r),await this.refreshRestoredWorkspaceTool(t.tool,i),this.git.updatePolling()}finally{this.routeRestoreInProgress=!1,this.restoringRouteTerminalId=void 0}}routeMatchesCurrentSelection(e){return 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){this.chatView?.saveScrollPosition(),await e(),await this.updateComplete,await this.chatView?.updateComplete,await mu(),this.chatView?.restoreScrollPosition(),this.shouldAutoFocusPrompt()&&this.promptEditor?.focusInput()}shouldAutoFocusPrompt(){return!this.isMobileNavigationLayout&&!this.isPwaDisplayMode}repairViewportPosition(){this.shouldRepairViewportPosition()&&(this.resetViewportScroll(),this.viewportPositionRepairFrame!==void 0&&window.cancelAnimationFrame(this.viewportPositionRepairFrame),this.viewportPositionRepairFrame=window.requestAnimationFrame(()=>{this.viewportPositionRepairFrame=void 0,this.resetViewportScroll(),this.viewportPositionRepairFrame=window.requestAnimationFrame(()=>{this.viewportPositionRepairFrame=void 0,this.resetViewportScroll()})}),this.viewportPositionRepairTimer!==void 0&&window.clearTimeout(this.viewportPositionRepairTimer),this.viewportPositionRepairTimer=window.setTimeout(()=>{this.viewportPositionRepairTimer=void 0,this.resetViewportScroll()},su))}shouldRepairViewportPosition(){return this.isMobileNavigationLayout||this.isPwaDisplayMode}resetViewportScroll(){window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0}clearViewportPositionRepair(){this.viewportPositionRepairFrame!==void 0&&(window.cancelAnimationFrame(this.viewportPositionRepairFrame),this.viewportPositionRepairFrame=void 0),this.viewportPositionRepairTimer!==void 0&&(window.clearTimeout(this.viewportPositionRepairTimer),this.viewportPositionRepairTimer=void 0)}async withChatPrependTransition(e){await e(),await this.updateComplete,await this.chatView?.updateComplete}defaultRouteView(){return this.isMobileNavigationLayout?"navigation":"chat"}updateUrl(e){Jc({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)}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){const t=this.terminalCommandRunRuntimes.get(e);if(t!==void 0)return t;const i=Yc(e,{openTerminal:(s,r)=>{this.openRuntimeTerminal(s,r)}});return this.terminalCommandRunRuntimes.set(e,i),i}async openRuntimeTerminal(e,t){e!==void 0&&this.state.selectedWorkspace?.id!==e.id&&await this.workspaces.selectWorkspace(e),this.openTerminal(t)}selectTerminal(e,t){this.rememberSelectedTerminal(e),this.setState({selectedTerminalId:e}),this.writeSelectedTerminalToUrl(e,t)}rememberSelectedTerminal(e){const t=this.state.selectedWorkspace;t!==void 0&&(e===void 0?this.terminalSelection.forgetWorkspace(t.path):this.terminalSelection.rememberTerminal(t.path,e))}writeSelectedTerminalToUrl(e,t){Qe(Js,"terminal",e,t)}selectMainView(e){if(e!=="navigation"&&e!=="chat"){this.openWorkspaceTool(e);return}this.setState({mainView:e}),this.updateUrl(),this.git.updatePolling()}handleWorkspaceChange(e,t){if(e.selectedWorkspace?.id===t.selectedWorkspace?.id)return;this.terminalAutoStartWorkspaceId=void 0,this.activeTerminalIds.clear();const i=this.routeRestoreInProgress?this.restoringRouteTerminalId:t.selectedWorkspace===void 0?void 0:this.terminalSelection.latestTerminalId(t.selectedWorkspace.path);this.setState({activeTerminalCount:0,selectedTerminalId:i}),this.routeRestoreInProgress||this.writeSelectedTerminalToUrl(i,{replace:!0}),t.selectedWorkspace!==void 0&&(this.refreshActiveTerminals(t.selectedWorkspace),this.refreshWorkspaceDeletionRuns(),this.refreshSelectedWorkspaceTool(t.workspaceTool),this.git.updatePolling())}connectRealtime(){this.realtime.connect(e=>{this.handleRealtimeEvent(e)},()=>{const e=this.state.selectedWorkspace;e!==void 0&&this.refreshActiveTerminals(e),this.refreshWorkspaceActivity()})}handleRealtimeEvent(e){e.type==="workspace.activity"?this.activity.applyWorkspaceActivity(e.activity):hu(e)?(this.applyTerminalEvent(e),e.type==="terminal.exited"&&this.refreshWorkspaceDeletionRuns()):this.sessions.applyGlobalEvent(e)}applyTerminalEvent(e){const t=this.state.selectedWorkspace;t===void 0||(e.type==="terminal.closed"?e.cwd:e.terminal.cwd)!==t.path||(e.type==="terminal.created"&&!e.terminal.exited?this.activeTerminalIds.add(e.terminal.id):this.activeTerminalIds.delete(e.type==="terminal.closed"?e.terminalId:e.terminal.id),e.type==="terminal.closed"&&(this.terminalSelection.forgetTerminal(e.terminalId),this.state.selectedTerminalId===e.terminalId&&this.selectTerminal(void 0,{replace:!0})),this.setState({activeTerminalCount:this.activeTerminalIds.size}))}async refreshActiveTerminals(e){try{const t=await fi.terminals(e.projectId,e.id);if(this.state.selectedWorkspace?.id!==e.id)return;this.activeTerminalIds.clear();for(const i of t)i.exited||this.activeTerminalIds.add(i.id);this.setState({activeTerminalCount:this.activeTerminalIds.size})}catch(t){this.setState({error:String(t)})}}handleActivityTransition(e,t){const i=Zs(e),s=Zs(t);i&&!s&&(this.setState({fileTreeStale:!0,gitStale:!0}),this.refreshSelectedWorkspaceTool(this.state.workspaceTool))}refreshSelectedWorkspaceTool(e){e==="core:workspace.files"&&this.files.refreshFiles(),e==="core:workspace.git"&&this.git.refreshGit()}renderWorkspacePanel(){const e=this.state.selectedWorkspace,t=e===void 0?void 0:this.createWorkspacePanelContext(e),i=e===void 0?[]:this.plugins.getWorkspaceLabelItems(this.state,e),s=e===void 0?this.workspacePanelEmptyState():void 0;return c`
|
|
1131
|
+
<workspace-panel
|
|
1132
|
+
id="workspace-panel"
|
|
1133
|
+
.workspace=${e}
|
|
1134
|
+
.panelContext=${t}
|
|
1135
|
+
.emptyState=${s}
|
|
1136
|
+
.tool=${this.state.workspaceTool}
|
|
1137
|
+
.panels=${this.visibleWorkspacePanels()}
|
|
1138
|
+
.workspaceLabelItems=${i}
|
|
1139
|
+
.onSelectTool=${r=>{this.openWorkspaceTool(r)}}
|
|
1140
|
+
></workspace-panel>
|
|
1141
|
+
`}toggleNavigationPanelCollapse(){this.navigationPanelCollapsed=!this.navigationPanelCollapsed}renderNavigationPanelEdgeControl(){const e=this.navigationPanelCollapsed,t=e?"Expand navigation panel":"Collapse navigation panel";return c`
|
|
1142
|
+
<div class="navigation-panel-edge">
|
|
1143
|
+
<button
|
|
1144
|
+
type="button"
|
|
1145
|
+
class="navigation-panel-edge-button"
|
|
1146
|
+
title=${t}
|
|
1147
|
+
aria-label=${t}
|
|
1148
|
+
aria-controls="navigation-panel"
|
|
1149
|
+
aria-expanded=${String(!e)}
|
|
1150
|
+
@click=${()=>{this.toggleNavigationPanelCollapse()}}
|
|
1151
|
+
>${this.renderNavigationPanelEdgeIcon(e)}</button>
|
|
1152
|
+
</div>
|
|
1153
|
+
`}renderNavigationPanelEdgeIcon(e){return this.renderPanelEdgeIcon(e?"right":"left","navigation-panel-edge-icon")}toggleWorkspacePanelCollapse(){this.workspacePanelCollapsed=!this.workspacePanelCollapsed}renderWorkspacePanelEdgeControl(){const e=this.workspacePanelCollapsed,t=e?"Expand workspace panel":"Collapse workspace panel";return c`
|
|
1154
|
+
<div class="workspace-panel-edge">
|
|
1155
|
+
<button
|
|
1156
|
+
type="button"
|
|
1157
|
+
class="workspace-panel-edge-button"
|
|
1158
|
+
title=${t}
|
|
1159
|
+
aria-label=${t}
|
|
1160
|
+
aria-controls="workspace-panel"
|
|
1161
|
+
aria-expanded=${String(!e)}
|
|
1162
|
+
@click=${()=>{this.toggleWorkspacePanelCollapse()}}
|
|
1163
|
+
>${this.renderWorkspacePanelEdgeIcon(e)}</button>
|
|
1164
|
+
</div>
|
|
1165
|
+
`}renderWorkspacePanelEdgeIcon(e){return this.renderPanelEdgeIcon(e?"left":"right","workspace-panel-edge-icon")}renderPanelEdgeIcon(e,t){return c`<svg class=${t} viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${e==="left"?"M15 18l-6-6 6-6":"M9 18l6-6-6-6"}/></svg>`}renderNavigationPanel(e){const t=i=>this.withChatScrollTransition(async()=>{await i(),e&&this.setState({mainView:"chat"}),e&&this.updateUrl()});return c`
|
|
1166
|
+
<header>
|
|
1167
|
+
<strong>PI WEB</strong>
|
|
1168
|
+
<div class="header-actions">
|
|
1169
|
+
${this.shouldShowAppRefreshInHeader()?this.renderAppRefresh():null}
|
|
1170
|
+
<button title="Show Actions" aria-label="Show Actions" @click=${()=>{this.setState({actionPaletteOpen:!0})}}>Actions</button>
|
|
1171
|
+
</div>
|
|
1172
|
+
</header>
|
|
1173
|
+
<project-list
|
|
1174
|
+
.projects=${this.state.projects}
|
|
1175
|
+
.selected=${this.state.selectedProject}
|
|
1176
|
+
.activities=${this.state.workspaceActivities}
|
|
1177
|
+
.workspacesByProjectId=${this.state.workspacesByProjectId}
|
|
1178
|
+
.collapsible=${this.isMobileNavigationLayout}
|
|
1179
|
+
.collapsed=${this.isNavigationSectionCollapsed("projects")}
|
|
1180
|
+
.onToggleCollapsed=${()=>{this.toggleNavigationSection("projects")}}
|
|
1181
|
+
.onSelect=${i=>this.withChatScrollTransition(async()=>{this.expandNavigationSection("workspaces"),await this.workspaces.selectProject(i)})}
|
|
1182
|
+
.onClose=${i=>this.projects.closeProject(i.id)}
|
|
1183
|
+
></project-list>
|
|
1184
|
+
<workspace-list
|
|
1185
|
+
.workspaces=${this.state.workspaces}
|
|
1186
|
+
.selected=${this.state.selectedWorkspace}
|
|
1187
|
+
.activities=${this.state.workspaceActivities}
|
|
1188
|
+
.deletingWorkspaceIds=${dc(this.state.workspaceDeletionRuns)}
|
|
1189
|
+
.collapsible=${this.isMobileNavigationLayout}
|
|
1190
|
+
.collapsed=${this.isNavigationSectionCollapsed("workspaces")}
|
|
1191
|
+
.workspaceLabelItems=${i=>this.plugins.getWorkspaceLabelItems(this.state,i)}
|
|
1192
|
+
.onToggleCollapsed=${()=>{this.toggleNavigationSection("workspaces")}}
|
|
1193
|
+
.onSelect=${i=>this.withChatScrollTransition(async()=>{this.expandNavigationSection("sessions"),await this.workspaces.selectWorkspace(i)})}
|
|
1194
|
+
.onDelete=${i=>{this.deleteWorkspace(i)}}
|
|
1195
|
+
></workspace-list>
|
|
1196
|
+
<session-list
|
|
1197
|
+
.sessions=${this.state.sessions}
|
|
1198
|
+
.statuses=${this.state.sessionStatuses}
|
|
1199
|
+
.activities=${this.state.sessionActivities}
|
|
1200
|
+
.selected=${this.state.selectedSession}
|
|
1201
|
+
.canStart=${!!this.state.selectedWorkspace}
|
|
1202
|
+
.collapsible=${this.isMobileNavigationLayout}
|
|
1203
|
+
.collapsed=${this.isNavigationSectionCollapsed("sessions")}
|
|
1204
|
+
.onToggleCollapsed=${()=>{this.toggleNavigationSection("sessions")}}
|
|
1205
|
+
.onArchivedCollapsed=${()=>{this.sessions.clearSelectionAfterArchivedCollapse()}}
|
|
1206
|
+
.onStart=${()=>t(()=>this.sessions.startSession())}
|
|
1207
|
+
.onSelect=${i=>t(()=>this.sessions.selectSession(i))}
|
|
1208
|
+
.onArchive=${i=>this.sessions.archiveSession(i)}
|
|
1209
|
+
.onArchiveWithDescendants=${i=>this.sessions.archiveSessionWithDescendants(i)}
|
|
1210
|
+
.onRestore=${i=>t(()=>this.sessions.restoreSession(i))}
|
|
1211
|
+
.onDelete=${i=>this.sessions.deleteCachedNewSession(i)}
|
|
1212
|
+
.onDetachParent=${i=>this.sessions.detachParent(i)}
|
|
1213
|
+
></session-list>
|
|
1214
|
+
`}expandedNavigationSection(){if(this.expandedMobileNavigationSection!=="none")return this.expandedMobileNavigationSection??this.defaultNavigationSection()}defaultNavigationSection(){return this.state.selectedProject===void 0?"projects":this.state.selectedWorkspace===void 0?"workspaces":"sessions"}isNavigationSectionCollapsed(e){return this.isMobileNavigationLayout&&this.expandedNavigationSection()!==e}toggleNavigationSection(e){this.isMobileNavigationLayout&&(this.expandedMobileNavigationSection=this.expandedNavigationSection()===e?"none":e)}expandNavigationSection(e){this.isMobileNavigationLayout&&(this.expandedMobileNavigationSection=e)}openNavigationSection(e){this.isMobileNavigationLayout&&(this.expandNavigationSection(e),this.selectMainView("navigation"))}visibleWorkspacePanels(){const e=this.state.selectedWorkspace;return e===void 0?[]:this.plugins.getWorkspacePanels().filter(t=>t.visible?.({workspace:e,state:this.state})??!0)}workspacePanelEmptyState(){const e=this.state.selectedProject;return this.state.isLoadingProjects?{title:"Loading projects…",body:"Looking for projects you have added to PI WEB."}:e===void 0?this.state.projects.length===0?{title:"No projects yet",body:"Use Actions → Add Project to add a folder. Workspace tools will appear here after you choose a workspace."}:{title:"Select a project",body:"Choose a project from the sidebar, then select a workspace to inspect files, Git, or terminals."}:this.state.isLoadingWorkspaces?{title:"Loading workspaces…",body:`Preparing workspace tools for ${e.name}.`}:this.state.workspaces.length===0?{title:"No workspaces found",body:`${e.name} does not have any available workspaces. Try selecting the project again or re-adding it.`}:{title:"Select a workspace",body:`Choose a workspace in ${e.name} to inspect files, Git, or terminals.`}}sessionEmptyMessage(){return this.state.isLoadingProjects?"Loading projects…":this.state.selectedWorkspace!==void 0?"Select or start a session.":this.state.selectedProject!==void 0?"Select a workspace to start a session.":this.state.projects.length===0?"Add a project to start a session.":"Select a project and workspace to start a session."}renderMobilePanelTitle(e){const t=this.state.selectedWorkspace;if(t===void 0)return e.title;const i=e.badge?.(this.createWorkspacePanelContext(t));return i===void 0||i===""?e.title:c`${e.title} <span class="tab-badge">${i}</span>`}createWorkspacePanelContext(e){const t=i=>Hc({workspace:e,state:this.state,piWebInternal:{terminalCommandRuns:this.terminalCommandRunsForOrigin(i)},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,openTerminal:s=>{this.openTerminal(s)},onRefreshFiles:()=>{this.files.refreshFiles()},onExpandDir:s=>{this.files.expandDir(s)},onSelectFile:s=>{this.files.selectFile(s)},onRefreshGit:()=>{this.git.refreshGit()},onSelectDiff:s=>{this.git.selectDiff(s)},onSelectTerminal:(s,r)=>{this.selectTerminal(s,r)}},t);return t("core")}getActions(){return this.plugins.getActions(this.createPluginRuntimeContext())}async loadExternalPlugins(){try{const e=await _c();for(const t of e)try{this.plugins.register(t)}catch(i){console.warn(`Failed to register PI WEB plugin ${t.id}`,i)}this.applyPreferredTheme(!1),this.requestUpdate()}catch(e){console.warn("Failed to load external PI WEB plugins",e)}}createPluginRuntimeContext(){const e=t=>qc({state:this.state,piWebInternal:{terminalCommandRuns:this.terminalCommandRunsForOrigin(t)},openActionPalette:()=>{this.setState({actionPaletteOpen:!0})},focusPrompt:()=>{this.promptEditor?.focusInput()},addProject:()=>{this.setState({projectDialogOpen:!0})},configureAuth:()=>this.auth.openLogin(),logoutAuth:()=>this.auth.openLogout(),openThemePicker:()=>{this.openThemeDialog()},selectMainView:i=>{this.selectMainView(i)},selectWorkspaceTool:i=>{this.openWorkspaceTool(i)},openTerminal:i=>{this.openTerminal(i)},refreshFiles:()=>this.files.refreshFiles(),refreshGit:()=>this.git.refreshGit(),refreshAppData:()=>this.refreshAppData(),reloadPage:()=>{this.hardReloadApp()},deleteWorkspace:i=>this.deleteWorkspace(i),startSession:()=>this.withChatScrollTransition(()=>this.sessions.startSession()),archiveSession:()=>this.sessions.archiveSession(),stopActiveWork:()=>this.sessions.stopActiveWork()},e);return e("core")}async deleteWorkspace(e=this.state.selectedWorkspace){if(e===void 0)return;if(!jl(e)){this.setState({error:"Only secondary Git worktrees can be deleted"});return}if(Ir(this.state,e))return;const t=e.branch??e.label;if(confirm(`Delete workspace ${t}?
|
|
1215
|
+
|
|
1216
|
+
This will run git worktree remove and delete:
|
|
1217
|
+
${e.path}
|
|
1218
|
+
|
|
1219
|
+
The Git branch will not be deleted.`))try{const s=await this.mainWorkspaceForProject(e.projectId);if(s===void 0){this.setState({error:"Project main workspace not found"});return}const r=await this.terminalCommandRunsForOrigin("core").runCommand({workspace:s,title:`Delete workspace: ${t}`,command:`git worktree remove ${uu(e.path)}`,open:!0,metadata:ac(e)});this.recordWorkspaceDeletionRun(r.run),r.completed.then(o=>this.handleCompletedWorkspaceDeletionRun(o)).catch(o=>{this.setState({error:`Workspace deletion failed. See terminal output. ${Xs(o)}`})})}catch(s){this.setState({error:`Failed to start workspace deletion: ${Xs(s)}`})}}async mainWorkspaceForProject(e){let t=this.state.selectedProject?.id===e?this.state.workspaces:this.state.workspacesByProjectId[e];return(t===void 0||t.length===0)&&(t=await this.workspaces.refreshProjectWorkspaces(e)),t.find(i=>i.isMain)??t[0]}recordWorkspaceDeletionRun(e){const t=ti(e);t!==void 0&&(this.setState({workspaceDeletionRuns:{...this.state.workspaceDeletionRuns,[t]:e}}),this.updateWorkspaceDeletionPolling())}async refreshWorkspaceDeletionRuns(){if(this.refreshingWorkspaceDeletionRuns)return;const e=this.state.selectedProject;if(e===void 0){this.setState({workspaceDeletionRuns:{}}),this.updateWorkspaceDeletionPolling();return}this.refreshingWorkspaceDeletionRuns=!0;try{const t=await this.terminalCommandRunsForOrigin("core").listCommandRuns(lc(e.id)),i=cc(t);this.setState({workspaceDeletionRuns:i});for(const s of Object.values(i))xt(s)||await this.handleCompletedWorkspaceDeletionRun(s)}catch(t){console.warn("Failed to refresh workspace deletion runs",t)}finally{this.refreshingWorkspaceDeletionRuns=!1,this.updateWorkspaceDeletionPolling()}}updateWorkspaceDeletionPolling(){const e=Object.values(this.state.workspaceDeletionRuns).some(xt);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){if(this.handledWorkspaceDeletionRunIds.has(e.id))return;const t=ti(e);if(t!==void 0){if(this.handledWorkspaceDeletionRunIds.add(e.id),e.status==="succeeded"){await this.workspaces.refreshAfterWorkspaceDeleted(e.projectId,t),this.setState({workspaceDeletionRuns:fu(this.state.workspaceDeletionRuns,t)}),this.updateWorkspaceDeletionPolling();return}e.status==="failed"&&(this.setState({error:"Workspace deletion failed. See terminal output."}),this.updateWorkspaceDeletionPolling())}}runAction(e){Promise.resolve().then(()=>e.run()).catch(t=>{const i=t instanceof Error?t.message:String(t);console.warn(`Action failed: ${e.id}`,t),this.setState({error:`Action failed: ${i}`})})}async openModelDialog(){const e=await this.sessions.listModels(),t=this.state.status?.model?.provider,i=this.state.status?.model?.id;this.setState({modelDialog:{title:"Select Model",...t!==void 0&&i!==void 0?{selectedValue:`${t}/${i}`}:{},options:e.map(s=>{const r=s.provider??"",o=s.id??"",n=r===t&&o===i;return{value:`${r}/${o}`,label:`${o}${n?" ✓ current":""}`,description:r}})}})}async pickModel(e){this.setState({modelDialog:void 0});const t=e.indexOf("/");t<=0||await this.sessions.setModel(e.slice(0,t),e.slice(t+1))}openThemeDialog(){const e=this.plugins.getThemes(),t=this.resolveCurrentThemePreference(e),i=t.selectedTheme?.id,s=this.themePreference.auto?Qs:Qt;this.setState({themeDialog:{title:"Select Theme",selectedValue:i===void 0?s:`${at}${i}`,options:[{value:s,label:`Auto ${this.themePreference.auto?"✓ on":"off"}`,description:this.autoThemeDescription(t)},...e.map(r=>({value:`${at}${r.id}`,label:this.themeOptionLabel(r,i),description:this.themeOptionDescription(r)}))]}})}pickTheme(e){if(this.setState({themeDialog:void 0}),e===Qt||e===Qs){const s=this.resolveCurrentThemePreference().selectedTheme?.id;if(s===void 0)return;this.themePreference={themeId:s,auto:e===Qt},this.applyPreferredTheme(!0);return}if(!e.startsWith(at))return;const t=e.slice(at.length),i=this.plugins.getThemes().find(s=>s.id===t);i!==void 0&&(this.themePreference={themeId:i.id,auto:this.themePreference.auto},this.applyPreferredTheme(!0))}applyPreferredTheme(e){const t=this.resolveCurrentThemePreference().activeTheme;t!==void 0&&(this.activeThemeId=t.id,Yl(t),e&&Xl(this.themePreference))}resolveCurrentThemePreference(e=this.plugins.getThemes()){return ec({themes:e,themePairs:this.plugins.getThemePairs(),preference:this.themePreference,prefersLight:this.systemPrefersLight()})}themePairForTheme(e){return $r(this.plugins.getThemePairs(),e)}systemPrefersLight(){return this.systemLightThemeMedia?.matches??!1}autoThemeDescription(e){return!this.themePreference.auto||e.selectedTheme===void 0?"Follow the system light/dark preference when the selected theme has a pair.":e.selectedThemePair===void 0?"On, but the selected theme has no light/dark pair, so it will stay selected.":`On · ${e.selectedThemePair.name} follows the system ${this.systemPrefersLight()?"light":"dark"} preference.`}themeOptionLabel(e,t){const i=[...e.id===t?["selected"]:[],...e.id===this.activeThemeId&&e.id!==t?["active"]:[]];return i.length===0?e.name:`${e.name} ✓ ${i.join(" · ")}`}themeOptionDescription(e){const t=[e.colorScheme];return this.themePairForTheme(e.id)!==void 0&&t.push("auto pair"),e.description!==void 0&&t.push(e.description),t.join(" · ")}async openThinkingDialog(){const e=await this.sessions.listThinkingLevels(),t=this.state.status?.thinkingLevel??"off";this.setState({thinkingDialog:{title:"Select Thinking Level",selectedValue:t,options:e.map(i=>({value:i,label:`${i}${i===t?" ✓ current":""}`,description:vu(i)}))}})}async pickThinking(e){this.setState({thinkingDialog:void 0}),gu(e)&&await this.sessions.setThinkingLevel(e)}sendPrompt(e,t){t===void 0&&this.auth.handleSlashCommand(e)||this.sessions.send(e,t)}renderContextBar(){const e=this.state.selectedProject,t=this.state.selectedWorkspace,i=this.state.selectedSession,s=ou(e),r=this.shouldShowAppRefreshInContextBar(),o=au(t),n=cu(i);return c`
|
|
1220
|
+
<nav class=${this.contextBarClass()} aria-label="Current location">
|
|
1221
|
+
<span class="context-bar-label">Location</span>
|
|
1222
|
+
<ol class="context-items" @scroll=${this.onContextScroll}>
|
|
1223
|
+
<li class="context-item">
|
|
1224
|
+
<button type="button" class=${e===void 0?"context-chip empty":"context-chip"} title=${nu(e)} aria-label=${`Project: ${s}. Open project selection.`} @click=${()=>{this.openNavigationSection("projects")}}>
|
|
1225
|
+
<span class="context-kind">Project</span>
|
|
1226
|
+
<span class="context-value">${s}</span>
|
|
1227
|
+
</button>
|
|
1228
|
+
</li>
|
|
1229
|
+
<li class="context-item">
|
|
1230
|
+
<button type="button" class=${t===void 0?"context-chip empty":"context-chip"} title=${lu(t)} aria-label=${`Workspace: ${o}. Open workspace selection.`} @click=${()=>{this.openNavigationSection("workspaces")}}>
|
|
1231
|
+
<span class="context-kind">Workspace</span>
|
|
1232
|
+
<span class="context-value">${o}</span>
|
|
1233
|
+
</button>
|
|
1234
|
+
</li>
|
|
1235
|
+
<li class="context-item">
|
|
1236
|
+
<button type="button" class=${i===void 0?"context-chip empty":"context-chip"} title=${du(i)} aria-label=${`Session: ${n}. Open session selection.`} @click=${()=>{this.openNavigationSection("sessions")}}>
|
|
1237
|
+
<span class="context-kind">Session</span>
|
|
1238
|
+
<span class="context-value">${n}</span>
|
|
1239
|
+
</button>
|
|
1240
|
+
</li>
|
|
1241
|
+
</ol>
|
|
1242
|
+
${r?c`<div class="context-actions">${this.renderAppRefresh()}</div>`:null}
|
|
1243
|
+
</nav>
|
|
1244
|
+
`}contextBarClass(){const e=["context-bar"];return this.shouldShowAppRefreshInContextBar()&&e.push("has-context-actions"),this.contextCanScrollLeft&&e.push("can-scroll-left"),this.contextCanScrollRight&&e.push("can-scroll-right"),e.join(" ")}shouldShowAppRefreshInHeader(){return this.isPwaDisplayMode&&!this.isMobileNavigationLayout}shouldShowAppRefreshInContextBar(){return this.isPwaDisplayMode&&this.isMobileNavigationLayout}mobileTabsFrameClass(){return`mobile-tabs-frame${this.mobileTabsCanScrollLeft?" can-scroll-left":""}${this.mobileTabsCanScrollRight?" can-scroll-right":""}`}observeContextItems(){const e=this.contextItemsElement();this.observedContextItems!==e&&(this.contextItemsResizeObserver?.disconnect(),this.observedContextItems=e,this.contextItemsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.contextItemsResizeObserver=new ResizeObserver(()=>{this.updateContextScrollState()}),this.contextItemsResizeObserver.observe(e)))}updateContextScrollState(){const e=this.contextItemsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.contextCanScrollLeft!==i&&(this.contextCanScrollLeft=i),this.contextCanScrollRight!==s&&(this.contextCanScrollRight=s)}contextItemsElement(){const e=this.contextItems;return e instanceof HTMLElement?e:void 0}observeMobileTabs(){const e=this.mobileTabsElement();this.observedMobileTabs!==e&&(this.mobileTabsResizeObserver?.disconnect(),this.observedMobileTabs=e,this.mobileTabsResizeObserver=void 0,!(e===void 0||typeof ResizeObserver>"u")&&(this.mobileTabsResizeObserver=new ResizeObserver(()=>{this.updateMobileTabsScrollState()}),this.mobileTabsResizeObserver.observe(e)))}updateMobileTabsScrollState(){const e=this.mobileTabsElement(),t=e===void 0?0:Math.max(0,e.scrollWidth-e.clientWidth),i=e!==void 0&&e.scrollLeft>1,s=e!==void 0&&t-e.scrollLeft>1;this.mobileTabsCanScrollLeft!==i&&(this.mobileTabsCanScrollLeft=i),this.mobileTabsCanScrollRight!==s&&(this.mobileTabsCanScrollRight=s)}mobileTabsElement(){const e=this.mobileTabs;return e instanceof HTMLElement?e:void 0}appRefreshElement(){const e=this.appRefresh;return e instanceof HTMLElement?e:void 0}renderAppRefresh(){const e=this.isRefreshingApp?"Refreshing app data. Long-press for reload options.":"Refresh app data. Long-press for reload options.";return c`
|
|
1245
|
+
<div class="app-refresh">
|
|
1246
|
+
<button
|
|
1247
|
+
class=${`app-refresh-button${this.isRefreshingApp?" refreshing":""}`}
|
|
1248
|
+
title=${e}
|
|
1249
|
+
aria-label=${e}
|
|
1250
|
+
aria-haspopup="menu"
|
|
1251
|
+
aria-expanded=${String(this.refreshMenuOpen)}
|
|
1252
|
+
aria-busy=${String(this.isRefreshingApp)}
|
|
1253
|
+
@click=${t=>{this.onRefreshClick(t)}}
|
|
1254
|
+
@contextmenu=${t=>{this.onRefreshContextMenu(t)}}
|
|
1255
|
+
@pointerdown=${t=>{this.onRefreshPointerDown(t)}}
|
|
1256
|
+
@pointerup=${()=>{this.clearRefreshLongPressTimer()}}
|
|
1257
|
+
@pointercancel=${()=>{this.clearRefreshLongPressTimer()}}
|
|
1258
|
+
@pointerleave=${()=>{this.clearRefreshLongPressTimer()}}
|
|
1259
|
+
>${this.renderRefreshIcon()}</button>
|
|
1260
|
+
</div>
|
|
1261
|
+
`}renderRefreshMenu(){return this.refreshMenuOpen?c`
|
|
1262
|
+
<div class="app-refresh-menu" role="menu" style=${this.refreshMenuStyle} @click=${e=>{e.stopPropagation()}}>
|
|
1263
|
+
<button role="menuitem" @click=${()=>{this.refreshAppData()}}>Refresh app data</button>
|
|
1264
|
+
<button role="menuitem" @click=${()=>{this.refreshMenuOpen=!1,this.suppressNextRefreshClick=!1,this.hardReloadApp()}}>Full page reload</button>
|
|
1265
|
+
</div>
|
|
1266
|
+
`:null}renderRefreshIcon(){return c`
|
|
1267
|
+
<svg class="app-refresh-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
1268
|
+
<path d="M20 6v5h-5"></path>
|
|
1269
|
+
<path d="M4 18v-5h5"></path>
|
|
1270
|
+
<path d="M18.2 9A7 7 0 0 0 6.1 6.8L4 9"></path>
|
|
1271
|
+
<path d="M5.8 15a7 7 0 0 0 12.1 2.2L20 15"></path>
|
|
1272
|
+
</svg>
|
|
1273
|
+
`}onRefreshClick(e){if(e.stopPropagation(),this.suppressNextRefreshClick){this.suppressNextRefreshClick=!1;return}this.refreshAppData()}onRefreshPointerDown(e){if(!e.isPrimary||e.button!==0)return;const t=e.currentTarget;t instanceof HTMLElement&&(this.clearRefreshLongPressTimer(),this.suppressNextRefreshClick=!1,this.refreshLongPressTimer=window.setTimeout(()=>{this.refreshLongPressTimer=void 0,this.suppressNextRefreshClick=!0,this.openRefreshMenu(t)},iu))}onRefreshContextMenu(e){e.preventDefault(),e.stopPropagation(),this.clearRefreshLongPressTimer(),this.suppressNextRefreshClick=!0,this.openRefreshMenu(e.currentTarget)}openRefreshMenu(e){this.refreshMenuStyle=Mt(e),this.refreshMenuOpen=!0}clearRefreshLongPressTimer(){this.refreshLongPressTimer!==void 0&&(window.clearTimeout(this.refreshLongPressTimer),this.refreshLongPressTimer=void 0)}render(){const e=this.state;return c`
|
|
1274
|
+
<div class=${`shell ${e.mainView==="navigation"?"navigation-view":e.mainView==="chat"?"chat-view":"workspace-view"}${this.navigationPanelCollapsed?" navigation-panel-collapsed":""}${this.workspacePanelCollapsed?" workspace-panel-collapsed":""}`}>
|
|
1275
|
+
<aside id="navigation-panel">${this.isMobileNavigationLayout?null:this.renderNavigationPanel(!1)}</aside>
|
|
1276
|
+
${this.renderNavigationPanelEdgeControl()}
|
|
1277
|
+
<main class=${e.mainView==="chat"?"chat-view":e.mainView==="navigation"?"navigation-view":"workspace-view"}>
|
|
1278
|
+
${this.renderContextBar()}
|
|
1279
|
+
<div class=${this.mobileTabsFrameClass()}>
|
|
1280
|
+
<div class="mobile-tabs" @scroll=${this.onMobileTabsScroll}>
|
|
1281
|
+
<button class=${e.mainView==="navigation"?"mobile-navigation-tab selected":"mobile-navigation-tab"} @click=${()=>{this.selectMainView("navigation")}}>Sessions</button>
|
|
1282
|
+
<button class=${e.mainView==="chat"?"selected":""} @click=${()=>{this.selectMainView("chat")}}>Chat</button>
|
|
1283
|
+
${this.visibleWorkspacePanels().map(t=>c`
|
|
1284
|
+
<button class=${e.mainView===t.id?"selected":""} @click=${()=>{this.openWorkspaceTool(t.id)}}>${this.renderMobilePanelTitle(t)}</button>
|
|
1285
|
+
`)}
|
|
1286
|
+
</div>
|
|
1287
|
+
</div>
|
|
1288
|
+
${e.error?c`<div class="error">${e.error}</div>`:null}
|
|
1289
|
+
<div class="mobile-navigation-panel">${this.isMobileNavigationLayout?this.renderNavigationPanel(!0):null}</div>
|
|
1290
|
+
${e.selectedSession?c`
|
|
1291
|
+
<chat-view .sessionId=${e.selectedSession.id} .messages=${e.messages} .messageStart=${e.messagePageStart} .messageEnd=${e.messagePageEnd} .messageTotal=${e.messagePageTotal} .hasMore=${e.messagePageStart>0} .loadingMore=${e.isLoadingEarlierMessages} .isReceivingPartialStream=${e.isReceivingPartialStream} .isCompacting=${e.status?.isCompacting===!0} .pendingMessageCount=${e.status?.pendingMessageCount??0} .status=${e.status} .activity=${e.activity} .onLoadMore=${()=>this.withChatPrependTransition(()=>this.sessions.loadEarlierMessages())}></chat-view>
|
|
1292
|
+
<prompt-editor .sessionId=${e.selectedSession.id} .cwd=${e.selectedWorkspace?.path} .disabled=${e.selectedSession.archived===!0} .canSteer=${e.status?.isStreaming===!0} .isCompacting=${e.status?.isCompacting===!0} .canStop=${e.status?.isStreaming===!0||e.status?.isBashRunning===!0||e.status?.isCompacting===!0||(e.status?.pendingMessageCount??0)>0} .status=${e.status} .onSend=${(t,i)=>{this.sendPrompt(t,i)}} .onStop=${()=>this.sessions.stopActiveWork()} .onSelectModel=${()=>{this.openModelDialog()}} .onSelectThinking=${()=>{this.openThinkingDialog()}}></prompt-editor>
|
|
1293
|
+
<status-bar .status=${e.status} .workspace=${e.selectedWorkspace} .workspaceLabelItems=${e.selectedWorkspace===void 0?[]:this.plugins.getWorkspaceLabelItems(e,e.selectedWorkspace)}></status-bar>
|
|
1294
|
+
${e.commandDialog!==void 0?c`<command-picker .title=${e.commandDialog.title} .options=${e.commandDialog.options} .onPick=${t=>this.sessions.respondToCommand(e.commandDialog?.requestId??"",t)} .onCancel=${()=>{this.sessions.cancelCommand()}}></command-picker>`:null}
|
|
1295
|
+
${e.modelDialog!==void 0?c`<command-picker title=${e.modelDialog.title} .searchable=${!0} .options=${e.modelDialog.options} .selectedValue=${e.modelDialog.selectedValue} .onPick=${t=>{this.pickModel(t)}} .onCancel=${()=>{this.setState({modelDialog:void 0})}}></command-picker>`:null}
|
|
1296
|
+
${e.thinkingDialog!==void 0?c`<command-picker title=${e.thinkingDialog.title} .options=${e.thinkingDialog.options} .selectedValue=${e.thinkingDialog.selectedValue} .onPick=${t=>{this.pickThinking(t)}} .onCancel=${()=>{this.setState({thinkingDialog:void 0})}}></command-picker>`:null}
|
|
1297
|
+
${e.authDialog!==void 0?c`<auth-dialog .state=${e.authDialog} .onChooseMethod=${t=>{this.auth.chooseLoginMethod(t)}} .onSelectProvider=${(t,i)=>{this.auth.selectLoginProvider(t,i)}} .onApiKeyInput=${t=>{this.auth.updateApiKey(t)}} .onSaveApiKey=${()=>{this.auth.saveApiKey()}} .onLogoutProvider=${t=>{this.auth.logoutProvider(t)}} .onOAuthInput=${t=>{this.auth.updateOAuthInput(t)}} .onOAuthRespond=${t=>{this.auth.respondOAuth(t)}} .onOAuthCancel=${()=>{this.auth.cancelOAuth()}} .onCancel=${()=>{this.auth.closeDialog()}}></auth-dialog>`:null}
|
|
1298
|
+
`:c`<div class="empty">${this.sessionEmptyMessage()}</div>`}
|
|
1299
|
+
</main>
|
|
1300
|
+
${this.renderWorkspacePanelEdgeControl()}
|
|
1301
|
+
${this.renderWorkspacePanel()}
|
|
1302
|
+
${e.actionPaletteOpen?c`<action-palette .actions=${this.getActions()} .onRun=${t=>{this.setState({actionPaletteOpen:!1}),this.runAction(t)}} .onCancel=${()=>{this.setState({actionPaletteOpen:!1})}}></action-palette>`:null}
|
|
1303
|
+
${e.projectDialogOpen?c`<project-dialog .onSubmit=${(t,i)=>this.projects.addProject(t,i)} .onCancel=${()=>{this.setState({projectDialogOpen:!1})}}></project-dialog>`:null}
|
|
1304
|
+
${e.themeDialog!==void 0?c`<command-picker title=${e.themeDialog.title} .options=${e.themeDialog.options} .selectedValue=${e.themeDialog.selectedValue} .onPick=${t=>{this.pickTheme(t)}} .onCancel=${()=>{this.setState({themeDialog:void 0})}}></command-picker>`:null}
|
|
1305
|
+
${this.renderRefreshMenu()}
|
|
1306
|
+
</div>
|
|
1307
|
+
`}};I.styles=pd;D([x()],I.prototype,"state",2);D([x()],I.prototype,"navigationPanelCollapsed",2);D([x()],I.prototype,"workspacePanelCollapsed",2);D([se("chat-view")],I.prototype,"chatView",2);D([se("prompt-editor")],I.prototype,"promptEditor",2);D([se(".context-items")],I.prototype,"contextItems",2);D([se(".mobile-tabs")],I.prototype,"mobileTabs",2);D([se(".app-refresh")],I.prototype,"appRefresh",2);D([x()],I.prototype,"activeThemeId",2);D([x()],I.prototype,"isMobileNavigationLayout",2);D([x()],I.prototype,"isPwaDisplayMode",2);D([x()],I.prototype,"isRefreshingApp",2);D([x()],I.prototype,"refreshMenuOpen",2);D([x()],I.prototype,"refreshMenuStyle",2);D([x()],I.prototype,"expandedMobileNavigationSection",2);D([x()],I.prototype,"contextCanScrollLeft",2);D([x()],I.prototype,"contextCanScrollRight",2);D([x()],I.prototype,"mobileTabsCanScrollLeft",2);D([x()],I.prototype,"mobileTabsCanScrollRight",2);I=D([F("pi-web-app")],I);function ru(){const e=new Bc;return e.register({id:"core",plugin:Ac}),e.register({id:"themes",plugin:Dc}),e}function ou(e){return e?.name??"No project"}function nu(e){return e===void 0?"No project selected":`${e.name} — ${e.path}`}function au(e){return e===void 0?"No workspace":`${e.label}${e.isMain?" · main":""} · ${e.path}`}function lu(e){return e===void 0?"No workspace selected":`${e.label}${e.isMain?" · main":""} — ${e.path}`}function cu(e){const t=e?.name?.trim(),i=e?.firstMessage.trim();return t!==void 0&&t!==""?t:i!==void 0&&i!==""?i:e?.id.slice(0,8)??"No session"}function du(e){return e===void 0?"No session selected":e.path}function pu(e,t){return Object.entries(t).some(([i,s])=>Reflect.get(e,i)!==s)}function Zs(e){return At(e.status,e.activity)}function hu(e){return e.type==="terminal.created"||e.type==="terminal.exited"||e.type==="terminal.closed"}function uu(e){return`'${e.replaceAll("'","'\\''")}'`}function Xs(e){return e instanceof Error?e.message:String(e)}function fu(e,t){return Object.fromEntries(Object.entries(e).filter(([i])=>i!==t))}function mu(){return new Promise(e=>requestAnimationFrame(()=>{e()}))}function gu(e){return e==="off"||e==="minimal"||e==="low"||e==="medium"||e==="high"||e==="xhigh"}function vu(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)"}}export{V as a,c as b,fi as c,Au as d,se as e,Cu as f,R as i,h as n,x as r,Iu as s,F as t};
|