pneuma-skills 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ ModeManifest(skill + viewer + agent_config) × AgentBackend × RuntimeShell
12
12
 
13
13
  ## Demo
14
14
 
15
- Ships with **Doc Mode** a markdown editing environment where Claude Code edits `.md` files and you see the rendered result in real-time.
15
+ Ships with **Doc Mode** (markdown editing) and **Slide Mode** (presentation editing). Here's Doc Mode — Claude Code edits `.md` files and you see the rendered result in real-time:
16
16
 
17
17
  ```
18
18
  ┌─────────────────────────────┬──────────────────────────┐
@@ -70,6 +70,7 @@ pneuma-skills <mode> [options]
70
70
 
71
71
  Modes:
72
72
  doc Markdown document editing mode
73
+ slide Presentation editing mode (HTML slides with iframe preview)
73
74
 
74
75
  Options:
75
76
  --workspace <path> Target workspace directory (default: current directory)
@@ -132,11 +133,16 @@ pneuma-skills/
132
133
  │ ├── mode-loader.ts # Dynamic mode discovery and loading
133
134
  │ └── __tests__/ # 42 contract tests
134
135
  ├── modes/
135
- └── doc/
136
- ├── pneuma-mode.ts # Doc Mode definition (manifest + viewer)
137
- ├── skill/SKILL.md # Skill prompt for Claude Code
136
+ ├── doc/
137
+ ├── pneuma-mode.ts # Doc Mode definition (manifest + viewer)
138
+ ├── skill/SKILL.md # Skill prompt for Claude Code
139
+ │ │ └── components/
140
+ │ │ └── DocPreview.tsx # Markdown preview with select/edit modes
141
+ │ └── slide/
142
+ │ ├── pneuma-mode.ts # Slide Mode definition (manifest + viewer)
143
+ │ ├── skill/ # Skill package (SKILL.md + design docs + scripts)
138
144
  │ └── components/
139
- │ └── DocPreview.tsx # Markdown preview with select/edit modes
145
+ │ └── SlidePreview.tsx # Slide carousel with iframe preview
140
146
  ├── backends/
141
147
  │ └── claude-code/
142
148
  │ ├── index.ts # ClaudeCodeBackend implements AgentBackend
@@ -162,9 +168,9 @@ pneuma-skills/
162
168
  │ ├── PermissionBanner.tsx # Tool permission approval UI
163
169
  │ └── TopBar.tsx # Tabs (Chat/Context/Terminal) + status
164
170
  └── docs/
165
- ├── architecture-review-v1.md # Architecture review & v1.0 blueprint
166
- ├── design/phase1-internal-decoupling.md # Detailed design doc
167
- └── adr/ # Architecture Decision Records (1-11)
171
+ ├── adr/ # Architecture Decision Records (1-11)
172
+ ├── design/ # Active design documents
173
+ └── archive/ # Completed design docs & references
168
174
  ```
169
175
 
170
176
  ## Tech Stack
@@ -197,12 +203,12 @@ pneuma-skills/
197
203
 
198
204
  ## Roadmap
199
205
 
200
- - [x] Doc Mode MVP — Markdown WYSIWYG editing
206
+ - [x] Doc Mode — Markdown WYSIWYG editing
207
+ - [x] Slide Mode — Presentation editing with iframe preview, drag-reorder, AI image generation
201
208
  - [x] Element selection & inline editing
202
209
  - [x] Session persistence & resume
203
210
  - [x] Terminal, tasks, context panel
204
211
  - [x] v1.0 contract architecture (ModeManifest, ViewerContract, AgentBackend)
205
- - [ ] Slide Mode — Presentation editing with iframe preview (v1.1)
206
212
  - [ ] Remote mode loading — `pneuma --mode github:user/repo` (v1.x)
207
213
  - [ ] Additional agent backends — Codex CLI, custom agents (v1.x)
208
214
 
package/bin/pneuma.ts CHANGED
@@ -168,6 +168,15 @@ function checkBunVersion() {
168
168
 
169
169
  async function main() {
170
170
  checkBunVersion();
171
+
172
+ // Snapshot subcommand — intercept before mode validation
173
+ const rawArgs = process.argv.slice(2);
174
+ if (rawArgs[0] === "snapshot") {
175
+ const { runSnapshot } = await import("../snapshot/index.js");
176
+ await runSnapshot(rawArgs.slice(1));
177
+ return;
178
+ }
179
+
171
180
  const { mode, workspace, port, noOpen } = parseArgs(process.argv);
172
181
 
173
182
  // Validate mode
@@ -219,9 +228,25 @@ async function main() {
219
228
  }
220
229
 
221
230
  // 1. Install skill + inject CLAUDE.md (driven by manifest)
222
- console.log("[pneuma] Installing skill and preparing environment...");
223
231
  const modeSourceDir = resolve(PROJECT_ROOT, "modes", mode);
224
- installSkill(workspace, manifest.skill, modeSourceDir, resolvedParams);
232
+ const skillTarget = join(workspace, ".claude", "skills", manifest.skill.installName);
233
+ let skipSkillInstall = false;
234
+
235
+ if (existsSync(skillTarget)) {
236
+ const answer = await ask(
237
+ `[pneuma] Existing skills found at ${skillTarget}\n` +
238
+ ` Replace with latest version? [Y/n] `,
239
+ );
240
+ if (answer.toLowerCase() === "n") {
241
+ skipSkillInstall = true;
242
+ console.log("[pneuma] Keeping existing skills.");
243
+ }
244
+ }
245
+
246
+ if (!skipSkillInstall) {
247
+ console.log("[pneuma] Installing skill and preparing environment...");
248
+ installSkill(workspace, manifest.skill, modeSourceDir, resolvedParams);
249
+ }
225
250
 
226
251
  // 1.5 Seed default content if workspace has no meaningful files
227
252
  if (manifest.init && manifest.init.contentCheckPattern) {
@@ -64,6 +64,8 @@ export interface InitParam {
64
64
  type: "number" | "string";
65
65
  /** 默认值 */
66
66
  defaultValue: number | string;
67
+ /** 标记为敏感值 (API key 等),snapshot 打包时会被清空 */
68
+ sensitive?: boolean;
67
69
  }
68
70
 
69
71
  /** 工作区初始化配置 — 描述空 workspace 时的初始化行为 */
@@ -1,4 +1,4 @@
1
- import{r as H,j as L,u as Fp}from"./index-CgTzYbqv.js";function $o(){return $o=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},$o.apply(null,arguments)}function Hp(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}let vo=[],TO=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?TO:vo).push(t=t+n[e])})();function Kp(n){if(n<768)return!1;for(let e=0,t=vo.length;;){let i=e+t>>1;if(n<vo[i])t=i;else if(n>=TO[i])e=i+1;else return!0;if(e==t)return!1}}function _a(n){return n>=127462&&n<=127487}const Wa=8205;function Jp(n,e,t=!0,i=!0){return(t?CO:em)(n,e,i)}function CO(n,e,t){if(e==n.length)return e;e&&XO(n.charCodeAt(e))&&ZO(n.charCodeAt(e-1))&&e--;let i=Cs(n,e);for(e+=Va(i);e<n.length;){let r=Cs(n,e);if(i==Wa||r==Wa||t&&Kp(r))e+=Va(r),i=r;else if(_a(r)){let s=0,o=e-2;for(;o>=0&&_a(Cs(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function em(n,e,t){for(;e>0;){let i=CO(n,e-2,t);if(i<e)return i;e--}return 0}function Cs(n,e){let t=n.charCodeAt(e);if(!ZO(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return XO(i)?(t-55296<<10)+(i-56320)+65536:t}function XO(n){return n>=56320&&n<57344}function ZO(n){return n>=55296&&n<56320}function Va(n){return n<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Ci(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),at.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ci(this,e,t);let i=[];return this.decompose(e,t,i,0),at.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new nn(this),s=new nn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new nn(this,e)}iterRange(e,t=this.length){return new RO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new AO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new oe(e):at.from(oe.split(e,[]))}}class oe extends I{constructor(e,t=tm(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new im(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new oe(La(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Sr(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new oe(l,o.length+s.length));else{let a=l.length>>1;i.push(new oe(l.slice(0,a)),new oe(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof oe))return super.replace(e,t,i);[e,t]=Ci(this,e,t);let r=Sr(this.text,Sr(i.text,La(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new oe(r,s):at.from(oe.split(r,[]),s)}sliceString(e,t=this.length,i=`
1
+ import{r as H,j as L,u as Fp}from"./index-J1QIN1v7.js";function $o(){return $o=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},$o.apply(null,arguments)}function Hp(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.indexOf(i)!==-1)continue;t[i]=n[i]}return t}let vo=[],TO=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?TO:vo).push(t=t+n[e])})();function Kp(n){if(n<768)return!1;for(let e=0,t=vo.length;;){let i=e+t>>1;if(n<vo[i])t=i;else if(n>=TO[i])e=i+1;else return!0;if(e==t)return!1}}function _a(n){return n>=127462&&n<=127487}const Wa=8205;function Jp(n,e,t=!0,i=!0){return(t?CO:em)(n,e,i)}function CO(n,e,t){if(e==n.length)return e;e&&XO(n.charCodeAt(e))&&ZO(n.charCodeAt(e-1))&&e--;let i=Cs(n,e);for(e+=Va(i);e<n.length;){let r=Cs(n,e);if(i==Wa||r==Wa||t&&Kp(r))e+=Va(r),i=r;else if(_a(r)){let s=0,o=e-2;for(;o>=0&&_a(Cs(n,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function em(n,e,t){for(;e>0;){let i=CO(n,e-2,t);if(i<e)return i;e--}return 0}function Cs(n,e){let t=n.charCodeAt(e);if(!ZO(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return XO(i)?(t-55296<<10)+(i-56320)+65536:t}function XO(n){return n>=56320&&n<57344}function ZO(n){return n>=55296&&n<56320}function Va(n){return n<65536?1:2}class I{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Ci(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),at.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ci(this,e,t);let i=[];return this.decompose(e,t,i,0),at.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new nn(this),s=new nn(e);for(let o=t,l=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new nn(this,e)}iterRange(e,t=this.length){return new RO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new AO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?I.empty:e.length<=32?new oe(e):at.from(oe.split(e,[]))}}class oe extends I{constructor(e,t=tm(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((t?i:l)>=e)return new im(r,l,i,o);r=l+1,i++}}decompose(e,t,i,r){let s=e<=0&&t>=this.length?this:new oe(La(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Sr(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new oe(l,o.length+s.length));else{let a=l.length>>1;i.push(new oe(l.slice(0,a)),new oe(l.slice(a)))}}else i.push(s)}replace(e,t,i){if(!(i instanceof oe))return super.replace(e,t,i);[e,t]=Ci(this,e,t);let r=Sr(this.text,Sr(i.text,La(this.text,0,e)),t),s=this.length+i.length-(t-e);return r.length<=32?new oe(r,s):at.from(oe.split(r,[]),s)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=Ci(this,e,t);let r="";for(let s=0,o=0;s<=t&&o<this.text.length;o++){let l=this.text[o],a=s+l.length;s>e&&o&&(r+=i),e<a&&t>s&&(r+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(t.push(new oe(i,r)),i=[],r=-1);return r>-1&&t.push(new oe(i,r)),t}}class at extends I{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,r);r=l+1,i=a+1}}decompose(e,t,i,r){for(let s=0,o=0;o<=t&&s<this.children.length;s++){let l=this.children[s],a=o+l.length;if(e<=a&&t>=o){let h=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=Ci(this,e,t),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e>=s&&t<=l){let a=o.replace(e-s,t-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[r]=a,new at(c,this.length-(t-e)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=Ci(this,e,t);let r="";for(let s=0,o=0;s<this.children.length&&o<=t;s++){let l=this.children[s],a=o+l.length;o>e&&s&&(r+=i),e<a&&t>o&&(r+=l.sliceString(e-o,t-o,i)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof at))return 0;let i=0,[r,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==l)return i;let a=this.children[r],h=e.children[s];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let u of e)i+=u.lines;if(i<32){let u=[];for(let d of e)d.flatten(u);return new oe(u,t)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],a=0,h=-1,c=[];function O(u){let d;if(u.lines>s&&u instanceof at)for(let m of u.children)O(m);else u.lines>o&&(a>o||!a)?(f(),l.push(u)):u instanceof oe&&a&&(d=c[c.length-1])instanceof oe&&u.lines+d.lines<=32?(a+=u.lines,h+=u.length+1,c[c.length-1]=new oe(d.text.concat(u.text),d.length+1+u.length)):(a+u.lines>r&&f(),a+=u.lines,h+=u.length+1,c.push(u))}function f(){a!=0&&(l.push(c.length==1?c[0]:at.from(c,h)),h=-1,a=c.length=0)}for(let u of e)O(u);return f(),l.length==1?l[0]:new at(l,t)}}I.empty=new oe([""],0);function tm(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Sr(n,e,t=0,i=1e9){for(let r=0,s=0,o=!0;s<n.length&&r<=i;s++){let l=n[s],a=r+l.length;a>=t&&(a>i&&(l=l.slice(0,i-r)),r<t&&(l=l.slice(t-r)),o?(e[e.length-1]+=l,o=!1):e.push(l)),r=a+1}return e}function La(n,e,t){return Sr(n,[""],e,t)}class nn{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof oe?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof oe?r.text.length:r.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
4
  `,this;e--}else if(r instanceof oe){let a=r.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof oe?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class RO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new nn(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=i?r:t<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class AO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(I.prototype[Symbol.iterator]=function(){return this.iter()},nn.prototype[Symbol.iterator]=RO.prototype[Symbol.iterator]=AO.prototype[Symbol.iterator]=function(){return this});let im=class{constructor(e,t,i,r){this.from=e,this.to=t,this.number=i,this.text=r}get length(){return this.to-this.from}};function Ci(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function pe(n,e,t=!0,i=!0){return Jp(n,e,t,i)}function nm(n){return n>=56320&&n<57344}function rm(n){return n>=55296&&n<56320}function Xe(n,e){let t=n.charCodeAt(e);if(!rm(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return nm(i)?(t-55296<<10)+(i-56320)+65536:t}function Rl(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function ht(n){return n<65536?1:2}const To=/\r\n?|\n/;var Se=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Se||(Se={}));class pt{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,r=0;t<this.sections.length;){let s=this.sections[t++],o=this.sections[t++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,t=!1){Co(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];r<0?e.push(i,r):e.push(r,i)}return new pt(e)}composeDesc(e){return this.empty?e:e.empty?this:qO(this,e)}mapDesc(e,t=!1){return e.empty?this:Xo(this,e,t)}mapPos(e,t=-1,i=Se.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=r+l;if(a<0){if(h>e)return s+(e-r);s+=l}else{if(i!=Se.Simple&&h>=e&&(i==Se.TrackDel&&r<e&&h>e||i==Se.TrackBefore&&r<e||i==Se.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==r||t<0?s:s+a;s+=a}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let i=0,r=0;i<this.sections.length&&r<=t;){let s=this.sections[i++],o=this.sections[i++],l=r+s;if(o>=0&&r<=t&&l>=e)return r<e&&l>t?"cover":!0;r=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],r=this.sections[t++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new pt(e)}static create(e){return new pt(e)}}class Oe extends pt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Co(this,(t,i,r,s,o)=>e=e.replace(r,r+(i-t),o),!1),e}mapDesc(e,t=!1){return Xo(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let r=0,s=0;r<t.length;r+=2){let o=t[r],l=t[r+1];if(l>=0){t[r]=l,t[r+1]=o;let a=r>>1;for(;i.length<a;)i.push(I.empty);i.push(o?e.slice(s,s+o):I.empty)}s+=o}return new Oe(t,i)}compose(e){return this.empty?e:e.empty?this:qO(this,e,!0)}map(e,t=!1){return e.empty?this:Xo(this,e,t,!0)}iterChanges(e,t=!1){Co(this,e,t)}get desc(){return pt.create(this.sections)}filter(e){let t=[],i=[],r=[],s=new fn(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&s.len==0;){if(s.done)break e;let c=Math.min(s.len,a-l);Pe(r,c,-1);let O=s.ins==-1?-1:s.off==0?s.ins:0;Pe(t,c,O),O>0&&Mt(i,t,s.text),s.forward(c),l+=c}let h=e[o++];for(;l<h;){if(s.done)break e;let c=Math.min(s.len,h-l);Pe(t,c,-1),Pe(r,c,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(c),l+=c}}return{changes:new Oe(t,i),filtered:pt.create(r)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],r=this.sections[t+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let r=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!r.length)return;o<t&&Pe(r,t-o,-1);let O=new Oe(r,s);l=l?l.compose(O.map(l)):O,r=[],s=[],o=0}function h(c){if(Array.isArray(c))for(let O of c)h(O);else if(c instanceof Oe){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:O,to:f=O,insert:u}=c;if(O>f||O<0||f>t)throw new RangeError(`Invalid change range ${O} to ${f} (in doc of length ${t})`);let d=u?typeof u=="string"?I.of(u.split(i||To)):u:I.empty,m=d.length;if(O==f&&m==0)return;O<o&&a(),O>o&&Pe(r,O-o,-1),Pe(r,f-O,m),Mt(s,r,d),o=f}}return h(e),a(!l),l}static empty(e){return new Oe(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")t.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;i.length<r;)i.push(I.empty);i[r]=I.of(s.slice(1)),t.push(s[0],i[r].length)}}}return new Oe(t,i)}static createSet(e,t){return new Oe(e,t)}}function Pe(n,e,t,i=!1){if(e==0&&t<=0)return;let r=n.length-2;r>=0&&t<=0&&t==n[r+1]?n[r]+=e:r>=0&&e==0&&n[r]==0?n[r+1]+=t:i?(n[r]+=e,n[r+1]+=t):n.push(e,t)}function Mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(I.empty);n.push(t)}}function Co(n,e,t){let i=n.inserted;for(let r=0,s=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,O=I.empty;for(;h+=l,c+=a,a&&i&&(O=O.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(r,h,s,c,O),r=h,s=c}}}function Xo(n,e,t,i=!1){let r=[],s=i?[]:null,o=new fn(n),l=new fn(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Pe(r,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Pe(r,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Pe(r,0,o.ins),s&&Mt(s,r,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let O=Math.min(c,l.len);h+=O,c-=O,l.forward(O)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Pe(r,h,a<o.i?o.ins:0),s&&a<o.i&&Mt(s,r,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return s?Oe.createSet(r,s):pt.create(r);throw new Error("Mismatched change set lengths")}}}function qO(n,e,t=!1){let i=[],r=t?[]:null,s=new fn(n),o=new fn(e);for(let l=!1;;){if(s.done&&o.done)return r?Oe.createSet(i,r):pt.create(i);if(s.ins==0)Pe(i,s.len,0,l),s.next();else if(o.len==0&&!o.done)Pe(i,0,o.ins,l),r&&Mt(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Pe(i,a,c,l),r&&c&&Mt(r,i,o.text)}else o.ins==-1?(Pe(i,s.off?0:s.len,a,l),r&&Mt(r,i,s.textBit(a))):(Pe(i,s.off?0:s.len,o.off?0:o.ins,l),r&&!o.off&&Mt(r,i,o.text));l=(s.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),s.forward2(a),o.forward(a)}}}}class fn{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?I.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?I.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ii{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new ii(i,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return y.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return y.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return y.range(e.anchor,e.head)}static create(e,t,i){return new ii(e,t,i)}}class y{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:y.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new y([this.main],0)}addRange(e,t=!0){return y.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,y.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new y(e.ranges.map(t=>ii.fromJSON(t)),e.main)}static single(e,t=e){return new y([y.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return y.normalized(e.slice(),t);i=s.to}return new y(e,t)}static cursor(e,t=0,i,r){return ii.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,t,i,r){let s=(i??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?ii.create(t,e,48|s):ii.create(e,t,(t>e?8:0)|s)}static normalized(e,t=0){let i=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let l=o.from,a=Math.max(s.to,o.to);r<=t&&t--,e.splice(--r,2,s.anchor>s.head?y.range(a,l):y.range(l,a))}}return new y(e,t)}}function zO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Al=0;class C{constructor(e,t,i,r,s){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=r,this.id=Al++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new C(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:ql),!!e.static,e.enables)}of(e){return new br([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new br(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new br(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function ql(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class br{constructor(e,t,i,r){this.dependencies=e,this.facet=t,this.type=i,this.value=r,this.id=Al++}dynamicSlot(e){var t;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let O of this.dependencies)O=="doc"?a=!0:O=="selection"?h=!0:(((t=e[O.id])!==null&&t!==void 0?t:1)&1)==0&&c.push(e[O.id]);return{create(O){return O.values[o]=i(O),1},update(O,f){if(a&&f.docChanged||h&&(f.docChanged||f.selection)||Zo(O,c)){let u=i(O);if(l?!Ya(u,O.values[o],r):!r(u,O.values[o]))return O.values[o]=u,1}return 0},reconfigure:(O,f)=>{let u,d=f.config.address[s];if(d!=null){let m=qr(f,d);if(this.dependencies.every(g=>g instanceof C?f.facet(g)===O.facet(g):g instanceof ye?f.field(g,!1)==O.field(g,!1):!0)||(l?Ya(u=i(O),m,r):r(u=i(O),m)))return O.values[o]=m,0}else u=i(O);return O.values[o]=u,1}}}}function Ya(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function Zo(n,e){let t=!1;for(let i of e)rn(n,i)&1&&(t=!0);return t}function sm(n,e,t){let i=t.map(a=>n[a.id]),r=t.map(a=>a.type),s=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let O=qr(a,i[c]);if(r[c]==2)for(let f of O)h.push(f);else h.push(O)}return e.combine(h)}return{create(a){for(let h of i)rn(a,h);return a.values[o]=l(a),1},update(a,h){if(!Zo(a,s))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=Zo(a,i),O=h.config.facets[e.id],f=h.facet(e);if(O&&!c&&ql(t,O))return a.values[o]=f,0;let u=l(a);return e.compare(u,f)?(a.values[o]=f,0):(a.values[o]=u,1)}}}const Gn=C.define({static:!0});class ye{constructor(e,t,i,r,s){this.id=e,this.createF=t,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let t=new ye(Al++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Gn).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,r)=>{let s=i.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[t]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Gn),o=r.facet(Gn),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):r.config.address[this.id]!=null?(i.values[t]=r.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Gn.of({field:this,create:e})]}get extension(){return this}}const Jt={lowest:4,low:3,default:2,high:1,highest:0};function ji(n){return e=>new MO(e,n)}const Zt={highest:ji(Jt.highest),high:ji(Jt.high),default:ji(Jt.default),low:ji(Jt.low),lowest:ji(Jt.lowest)};class MO{constructor(e,t){this.inner=e,this.prec=t}}class fs{of(e){return new Ro(this,e)}reconfigure(e){return fs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Ro{constructor(e,t){this.compartment=e,this.inner=t}}class Ar{constructor(e,t,i,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let r=[],s=Object.create(null),o=new Map;for(let f of om(e,t,o))f instanceof ye?r.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],h=[];for(let f of r)l[f.id]=h.length<<1,h.push(u=>f.slot(u));let c=i==null?void 0:i.config.facets;for(let f in s){let u=s[f],d=u[0].facet,m=c&&c[f]||[];if(u.every(g=>g.type==0))if(l[d.id]=a.length<<1|1,ql(m,u))a.push(i.facet(d));else{let g=d.combine(u.map(Q=>Q.value));a.push(i&&d.compare(g,i.facet(d))?i.facet(d):g)}else{for(let g of u)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(Q=>g.dynamicSlot(Q)));l[d.id]=h.length<<1,h.push(g=>sm(g,d,u))}}let O=h.map(f=>f(l));return new Ar(e,o,O,l,a,s)}}function om(n,e,t){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let a=r.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof Ro&&t.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let h of o)s(h,l);else if(o instanceof Ro){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),s(h,l)}else if(o instanceof MO)s(o.inner,o.prec);else if(o instanceof ye)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof br)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,Jt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,l)}}return s(n,Jt.default),i.reduce((o,l)=>o.concat(l))}function rn(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let r=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|r}function qr(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const EO=C.define(),Ao=C.define({combine:n=>n.some(e=>e),static:!0}),_O=C.define({combine:n=>n.length?n[0]:void 0,static:!0}),WO=C.define(),VO=C.define(),LO=C.define(),YO=C.define({combine:n=>n.length?n[0]:!1});class gt{constructor(e,t){this.type=e,this.value=t}static define(){return new lm}}class lm{of(e){return new gt(this,e)}}class am{constructor(e){this.map=e}of(e){return new z(this,e)}}class z{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new z(this.type,t)}is(e){return this.type==e}static define(e={}){return new am(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(t);s&&i.push(s)}return i}}z.reconfigure=z.define();z.appendConfig=z.define();class ae{constructor(e,t,i,r,s,o){this.startState=e,this.changes=t,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&zO(i,t.newLength),s.some(l=>l.type==ae.time)||(this.annotations=s.concat(ae.time.of(Date.now())))}static create(e,t,i,r,s,o){return new ae(e,t,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ae.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ae.time=gt.define();ae.userEvent=gt.define();ae.addToHistory=gt.define();ae.remote=gt.define();function hm(n,e){let t=[];for(let i=0,r=0;;){let s,o;if(i<n.length&&(r==e.length||e[r]>=n[i]))s=n[i++],o=n[i++];else if(r<e.length)s=e[r++],o=e[r++];else return t;!t.length||t[t.length-1]<s?t.push(s,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function jO(n,e,t){var i;let r,s,o;return t?(r=e.changes,s=Oe.empty(e.changes.length),o=n.changes.compose(e.changes)):(r=e.changes.map(n.changes),s=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=n.selection)===null||i===void 0?void 0:i.map(r),effects:z.mapEffects(n.effects,r).concat(z.mapEffects(e.effects,s)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function qo(n,e,t){let i=e.selection,r=bi(e.annotations);return e.userEvent&&(r=r.concat(ae.userEvent.of(e.userEvent))),{changes:e.changes instanceof Oe?e.changes:Oe.of(e.changes||[],t,n.facet(_O)),selection:i&&(i instanceof y?i:y.single(i.anchor,i.head)),effects:bi(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function DO(n,e,t){let i=qo(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(t=!1);let o=!!e[s].sequential;i=jO(i,qo(n,e[s],o?i.changes.newLength:n.doc.length),o)}let r=ae.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Om(t?cm(r):r)}function cm(n){let e=n.startState,t=!0;for(let r of e.facet(WO)){let s=r(n);if(s===!1){t=!1;break}Array.isArray(s)&&(t=t===!0?s:hm(t,s))}if(t!==!0){let r,s;if(t===!1)s=n.changes.invertedDesc,r=Oe.empty(e.doc.length);else{let o=n.changes.filter(t);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}n=ae.create(e,r,n.selection&&n.selection.map(s),z.mapEffects(n.effects,s),n.annotations,n.scrollIntoView)}let i=e.facet(VO);for(let r=i.length-1;r>=0;r--){let s=i[r](n);s instanceof ae?n=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ae?n=s[0]:n=DO(e,bi(s),!1)}return n}function Om(n){let e=n.startState,t=e.facet(LO),i=n;for(let r=t.length-1;r>=0;r--){let s=t[r](n);s&&Object.keys(s).length&&(i=jO(i,qo(e,s,n.changes.newLength),!0))}return i==n?n:ae.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const fm=[];function bi(n){return n==null?fm:Array.isArray(n)?n:[n]}var ne=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(ne||(ne={}));const um=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let zo;try{zo=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function dm(n){if(zo)return zo.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||um.test(t)))return!0}return!1}function pm(n){return e=>{if(!/\S/.test(e))return ne.Space;if(dm(e))return ne.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return ne.Word;return ne.Other}}class D{constructor(e,t,i,r,s,o){this.config=e,this.doc=t,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)rn(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return rn(this,i),qr(this,i)}update(...e){return DO(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:r}=t;for(let l of e.effects)l.is(fs.reconfigure)?(t&&(r=new Map,t.compartments.forEach((a,h)=>r.set(h,a)),t=null),r.set(l.value.compartment,l.value.extension)):l.is(z.reconfigure)?(t=null,i=l.value):l.is(z.appendConfig)&&(t=null,i=bi(i).concat(l.value));let s;t?s=e.startState.values.slice():(t=Ar.resolve(i,r,this),s=new D(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Ao)?e.newSelection:e.newSelection.asSingle();new D(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:y.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),r=this.changes(i.changes),s=[i.range],o=bi(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(r);for(let f=0;f<l;f++)s[f]=s[f].map(c);let O=r.mapDesc(h,!0);s.push(a.range.map(O)),r=r.compose(c),o=z.mapEffects(o,c).concat(z.mapEffects(bi(a.effects),O))}return{changes:r,selection:y.create(s,t.mainIndex),effects:o}}changes(e=[]){return e instanceof Oe?e:Oe.of(e,this.doc.length,this.facet(D.lineSeparator))}toText(e){return I.of(e.split(this.facet(D.lineSeparator)||To))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(rn(this,t),qr(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof ye&&this.config.address[r.id]!=null&&(t[i]=r.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],l=e[s];r.push(o.init(a=>o.spec.fromJSON(l,a)))}}return D.create({doc:e.doc,selection:y.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Ar.resolve(e.extensions||[],new Map),i=e.doc instanceof I?e.doc:I.of((e.doc||"").split(t.staticFacet(D.lineSeparator)||To)),r=e.selection?e.selection instanceof y?e.selection:y.single(e.selection.anchor,e.selection.head):y.single(0);return zO(r,i.length),t.staticFacet(Ao)||(r=r.asSingle()),new D(t,i,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(D.tabSize)}get lineBreak(){return this.facet(D.lineSeparator)||`
@@ -1,4 +1,4 @@
1
- import{u as os,r as We,j as Ye}from"./index-CgTzYbqv.js";/**
1
+ import{u as os,r as We,j as Ye}from"./index-J1QIN1v7.js";/**
2
2
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
3
3
  * @license MIT
4
4
  *
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pneuma-mode-r4_sojXe.js","assets/manifest-D0B-XRFy.js","assets/pneuma-mode-CjWVuMga.js","assets/manifest-CYNgEFXq.js","assets/TerminalPanel-DlXrAk_5.js","assets/TerminalPanel-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pneuma-mode-C4v13scm.js","assets/manifest-D0B-XRFy.js","assets/pneuma-mode-_Ng_oSnc.js","assets/manifest-DGD2_XYa.js","assets/TerminalPanel-xx5i__-P.js","assets/TerminalPanel-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
2
  var Cp=n=>{throw TypeError(n)};var Ep=(n,l,a)=>l.has(n)||Cp("Cannot "+a);var Ua=(n,l,a)=>(Ep(n,l,"read from private field"),a?a.call(n):l.get(n)),Tp=(n,l,a)=>l.has(n)?Cp("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(n):l.set(n,a),zp=(n,l,a,u)=>(Ep(n,l,"write to private field"),u?u.call(n,a):l.set(n,a),a);(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))u(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const f of o.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&u(f)}).observe(document,{childList:!0,subtree:!0});function a(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function u(s){if(s.ep)return;s.ep=!0;const o=a(s);fetch(s.href,o)}})();function ef(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var sc={exports:{}},Ha={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -92,4 +92,4 @@ Error generating stack: `+r.message+`
92
92
  `+n}const f={type:"user_message",content:s};a!=null&&a.length&&(f.images=a),ir(f)}function Ig(n,l,a){de.getState().removePermission(n),ir({type:"permission_response",request_id:n,behavior:l,updated_input:a})}function XE(){ir({type:"interrupt"})}function QE(){const n=de(l=>l.pendingPermissions);return n.size===0?null:b.jsx("div",{className:"space-y-2 p-3",children:Array.from(n.values()).map(l=>b.jsxs("div",{className:"bg-amber-900/40 border border-amber-700/50 rounded-lg p-3",children:[b.jsxs("div",{className:"text-sm font-medium text-amber-200 mb-1",children:["Permission Request: ",l.tool_name]}),l.description&&b.jsx("div",{className:"text-xs text-amber-300/80 mb-2",children:l.description}),b.jsx("div",{className:"text-xs text-neutral-400 mb-2 font-mono max-h-32 overflow-y-auto bg-neutral-900/50 rounded p-2",children:JSON.stringify(l.input,null,2)}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx("button",{onClick:()=>Ig(l.request_id,"allow"),className:"px-3 py-1 text-xs bg-green-700 hover:bg-green-600 text-white rounded transition-colors",children:"Allow"}),b.jsx("button",{onClick:()=>Ig(l.request_id,"deny"),className:"px-3 py-1 text-xs bg-red-700 hover:bg-red-600 text-white rounded transition-colors",children:"Deny"})]})]},l.request_id))})}const _y=[{id:"claude-opus-4-6",label:"Opus",icon:"O"},{id:"claude-sonnet-4-6",label:"Sonnet",icon:"S"},{id:"claude-haiku-4-5-20251001",label:"Haiku",icon:"H"}],Kc=_y[0];function FE(n){return n?n.toLowerCase().includes("opus")?{label:"Opus",icon:"O"}:n.toLowerCase().includes("sonnet")?{label:"Sonnet",icon:"S"}:n.toLowerCase().includes("haiku")?{label:"Haiku",icon:"H"}:{label:n.split("-").slice(0,2).join("-"),icon:"?"}:Kc}function ZE(){const n=de(o=>{var f;return((f=o.session)==null?void 0:f.model)??""}),[l,a]=le.useState(!1),u=le.useRef(null);le.useEffect(()=>{if(!l)return;const o=f=>{u.current&&!u.current.contains(f.target)&&a(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[l]);const s=FE(n);return b.jsxs("div",{ref:u,className:"relative",children:[b.jsxs("button",{onClick:()=>a(o=>!o),className:"flex items-center gap-1.5 px-2 py-1 text-xs text-neutral-400 hover:text-neutral-200 bg-neutral-800 hover:bg-neutral-700 rounded transition-colors",title:n||Kc.id,children:[b.jsx("span",{className:"w-4 h-4 rounded bg-neutral-700 flex items-center justify-center text-[10px] font-bold text-neutral-300",children:s.icon}),b.jsx("span",{children:s.label}),b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:b.jsx("path",{d:"M4 10l4-4 4 4"})})]}),l&&b.jsx("div",{className:"absolute bottom-full left-0 mb-1 bg-neutral-800 border border-neutral-700 rounded-md shadow-lg overflow-hidden z-50",children:_y.map(o=>{const f=n?n.toLowerCase().includes(o.label.toLowerCase()):o.id===Kc.id;return b.jsxs("button",{onClick:()=>{YE(o.id),a(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left whitespace-nowrap transition-colors ${f?"bg-neutral-700 text-neutral-100":"text-neutral-400 hover:bg-neutral-750 hover:text-neutral-200"}`,children:[b.jsx("span",{className:"w-4 h-4 rounded bg-neutral-600 flex items-center justify-center text-[10px] font-bold text-neutral-200 shrink-0",children:o.icon}),b.jsx("span",{children:o.label})]},o.id)})})]})}function IE({items:n,selectedIndex:l,onSelect:a}){const u=le.useRef(null);return le.useEffect(()=>{var o;const s=(o=u.current)==null?void 0:o.children[l];s==null||s.scrollIntoView({block:"nearest"})},[l]),n.length===0?null:b.jsx("div",{ref:u,className:"absolute bottom-full left-0 mb-1 w-64 max-h-48 overflow-y-auto bg-neutral-800 border border-neutral-700 rounded-md shadow-lg z-50",children:n.map((s,o)=>b.jsxs("button",{onMouseDown:f=>{f.preventDefault(),a(s)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs text-left transition-colors ${o===l?"bg-neutral-700 text-neutral-100":"text-neutral-400 hover:bg-neutral-750 hover:text-neutral-200"}`,children:[b.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-neutral-500 shrink-0",children:s.kind==="skill"?b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:b.jsx("path",{d:"M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25z"})}):b.jsx("span",{className:"text-[11px] font-bold",children:"/"})}),b.jsxs("span",{className:"truncate",children:["/",s.name]})]},s.name))})}const Jg=[];function JE(n){const a={heading:`h${n.level||1}`,paragraph:"paragraph",list:"list",code:"code block",blockquote:"blockquote",image:"image",table:"table","text-range":"text"}[n.type]||n.type,u=n.content.length>60?n.content.slice(0,57)+"...":n.content;return`${a}: "${u}"`}let KE=0;function PE(n){return new Promise(l=>{if(!n.type.startsWith("image/")){l(null);return}const a=new FileReader;a.onload=()=>{const u=a.result,s=u.split(",")[1];l({id:`img-${Date.now()}-${++KE}`,media_type:n.type,data:s,preview:u})},a.onerror=()=>l(null),a.readAsDataURL(n)})}function $E(){const[n,l]=le.useState(""),[a,u]=le.useState([]),[s,o]=le.useState(!1),[f,h]=le.useState(""),[m,p]=le.useState(0),y=le.useRef(null),g=le.useRef(null),S=de(D=>D.cliConnected),v=de(D=>D.turnInProgress),C=de(D=>D.selection),j=de(D=>D.setSelection),M=de(D=>{var P;return((P=D.session)==null?void 0:P.slash_commands)??Jg}),A=de(D=>{var P;return((P=D.session)==null?void 0:P.skills)??Jg}),L=v,O=le.useMemo(()=>{const D=new Set(A);return M.map(P=>({name:P,kind:D.has(P)?"skill":"command"}))},[M,A]),Q=le.useMemo(()=>{if(!f)return O;const D=f.toLowerCase(),P=O.filter(ue=>ue.name.toLowerCase().includes(D));return P.sort((ue,E)=>{const z=ue.name.toLowerCase(),V=E.name.toLowerCase(),w=z===D;if(w!==(V===D))return w?-1:1;const he=z.startsWith(D),fe=V.startsWith(D);return he!==fe?he?-1:1:0}),P},[O,f]);le.useEffect(()=>{p(0)},[f]);const Z=le.useCallback(()=>{const D=n.trim();if(!D&&a.length===0)return;const P=a.length>0?a.map(ue=>({media_type:ue.media_type,data:ue.data})):void 0;VE(D,C,P),l(""),u([]),j(null),o(!1),y.current&&(y.current.style.height="auto"),de.getState().setTurnInProgress(!0)},[n,a,C,j]),B=D=>{if(s&&Q.length>0){if(D.key==="ArrowDown"){D.preventDefault(),p(P=>(P+1)%Q.length);return}if(D.key==="ArrowUp"){D.preventDefault(),p(P=>(P-1+Q.length)%Q.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault(),W(Q[m]);return}if(D.key==="Escape"){D.preventDefault(),o(!1);return}}D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Z())},W=D=>{var E;const P=n.lastIndexOf("/"),ue=P>0?n.slice(0,P):"";l(`${ue}/${D.name} `),o(!1),(E=y.current)==null||E.focus()},re=D=>{l(D);const P=D.lastIndexOf("/");if(P>=0&&(P===0||D[P-1]===" "||D[P-1]===`
93
93
  `)){const ue=D.slice(P+1);ue.includes(" ")||ue.includes(`
94
94
  `)?o(!1):(o(!0),h(ue))}else o(!1)},pe=()=>{const D=y.current;D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,200)}px`)},q=le.useCallback(async D=>{const P=Array.from(D),E=(await Promise.all(P.map(PE))).filter(z=>z!==null);E.length>0&&u(z=>[...z,...E])},[]),K=D=>{u(P=>P.filter(ue=>ue.id!==D))},$=le.useCallback(D=>{var E;const P=(E=D.clipboardData)==null?void 0:E.items;if(!P)return;const ue=[];for(const z of P)if(z.type.startsWith("image/")){const V=z.getAsFile();V&&ue.push(V)}ue.length>0&&(D.preventDefault(),q(ue))},[q]),ce=D=>{D.preventDefault(),D.dataTransfer.dropEffect="copy"},ie=le.useCallback(D=>{var ue;D.preventDefault();const P=(ue=D.dataTransfer)==null?void 0:ue.files;P!=null&&P.length&&q(P)},[q]),ee=()=>{var D;(D=g.current)==null||D.click()},R=D=>{var P;(P=D.target.files)!=null&&P.length&&(q(D.target.files),D.target.value="")};return b.jsxs("div",{className:"p-3 border-t border-neutral-800",children:[C&&b.jsx("div",{className:"flex items-center gap-2 mb-2 px-1",children:b.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-cc-primary/15 text-cc-primary text-xs max-w-full overflow-hidden",children:[b.jsx(WE,{}),b.jsx("span",{className:"truncate",children:JE(C)}),b.jsxs("span",{className:"shrink-0 text-cc-muted mx-0.5",children:["in ",C.file]}),b.jsx("button",{onClick:()=>j(null),className:"shrink-0 ml-0.5 hover:text-cc-fg transition-colors cursor-pointer",title:"Clear selection",children:b.jsx(Kg,{})})]})}),a.length>0&&b.jsx("div",{className:"flex items-center gap-2 mb-2 px-1 overflow-x-auto",children:a.map(D=>b.jsxs("div",{className:"relative shrink-0 group",children:[b.jsx("img",{src:D.preview,alt:"",className:"w-14 h-14 rounded-md object-cover border border-neutral-700"}),b.jsx("button",{onClick:()=>K(D.id),className:"absolute top-0.5 right-0.5 w-4 h-4 bg-neutral-700/80 hover:bg-red-600 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:b.jsx(Kg,{})})]},D.id))}),b.jsxs("div",{className:"relative",onDragOver:ce,onDrop:ie,children:[s&&Q.length>0&&b.jsx(IE,{items:Q,selectedIndex:m,onSelect:W}),b.jsx("textarea",{ref:y,value:n,onChange:D=>re(D.target.value),onKeyDown:B,onInput:pe,onPaste:$,placeholder:S?L?"Claude is working...":C?"Tell Claude what to change...":"Send a message... (paste images, type / for commands)":"Waiting for CLI connection...",disabled:!S||L,rows:1,className:"w-full bg-neutral-800 text-neutral-100 rounded-lg px-3 py-2 text-sm resize-none placeholder-neutral-500 focus:outline-none focus:ring-1 focus:ring-neutral-600 disabled:opacity-50"})]}),b.jsxs("div",{className:"flex items-center justify-between mt-2",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(ZE,{}),b.jsxs("button",{onClick:ee,className:"flex items-center gap-1 px-2 py-1 text-xs text-neutral-500 hover:text-neutral-300 bg-neutral-800 hover:bg-neutral-700 rounded transition-colors",title:"Attach image",children:[b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:b.jsx("path",{d:"M8 2a.75.75 0 01.75.75v4.5h4.5a.75.75 0 010 1.5h-4.5v4.5a.75.75 0 01-1.5 0v-4.5h-4.5a.75.75 0 010-1.5h4.5v-4.5A.75.75 0 018 2z"})}),b.jsx("span",{children:"Image"})]}),b.jsx("input",{ref:g,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:R})]}),b.jsx("div",{children:L?b.jsx("button",{onClick:XE,className:"px-4 py-1.5 bg-red-700 hover:bg-red-600 text-white text-xs rounded-lg transition-colors",children:"Stop"}):b.jsx("button",{onClick:Z,disabled:!n.trim()&&a.length===0||!S,className:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-xs rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Send"})})]})]})}function WE(){return b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3 shrink-0",children:b.jsx("path",{d:"M9.828 1.282a.75.75 0 011.06 0l3.83 3.83a.75.75 0 010 1.06l-3.17 3.17a.75.75 0 01-.254.166l-1.97.738.738-1.97a.75.75 0 01.166-.254l3.17-3.17-2.77-2.77-3.17 3.17a.75.75 0 01-.254.166l-1.97.738.738-1.97a.75.75 0 01.166-.254l3.17-3.17a.75.75 0 010-1.06zM1.5 14.5l4-4"})})}function Kg(){return b.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:b.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})}function eT(){const n=de(o=>o.messages),l=de(o=>o.streaming),a=de(o=>o.activity),u=de(o=>o.cliConnected),s=le.useRef(null);return le.useEffect(()=>{var o;(o=s.current)==null||o.scrollIntoView({behavior:"smooth"})},[n.length,l,a]),b.jsxs("div",{className:"flex flex-col h-full",children:[b.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:[n.length===0&&!l&&!a&&b.jsx("div",{className:"text-cc-muted text-sm text-center mt-8",children:u?"Send a message to start editing":"Connecting to Claude..."}),n.map(o=>b.jsx(gE,{message:o},o.id)),l?b.jsx(NE,{}):a?b.jsx(ME,{}):null,b.jsx("div",{ref:s})]}),b.jsx(QE,{}),b.jsx($E,{})]})}class tT{diff(l,a,u={}){let s;typeof u=="function"?(s=u,u={}):"callback"in u&&(s=u.callback);const o=this.castInput(l,u),f=this.castInput(a,u),h=this.removeEmpty(this.tokenize(o,u)),m=this.removeEmpty(this.tokenize(f,u));return this.diffWithOptionsObj(h,m,u,s)}diffWithOptionsObj(l,a,u,s){var o;const f=L=>{if(L=this.postProcess(L,u),s){setTimeout(function(){s(L)},0);return}else return L},h=a.length,m=l.length;let p=1,y=h+m;u.maxEditLength!=null&&(y=Math.min(y,u.maxEditLength));const g=(o=u.timeout)!==null&&o!==void 0?o:1/0,S=Date.now()+g,v=[{oldPos:-1,lastComponent:void 0}];let C=this.extractCommon(v[0],a,l,0,u);if(v[0].oldPos+1>=m&&C+1>=h)return f(this.buildValues(v[0].lastComponent,a,l));let j=-1/0,M=1/0;const A=()=>{for(let L=Math.max(j,-p);L<=Math.min(M,p);L+=2){let O;const Q=v[L-1],Z=v[L+1];Q&&(v[L-1]=void 0);let B=!1;if(Z){const re=Z.oldPos-L;B=Z&&0<=re&&re<h}const W=Q&&Q.oldPos+1<m;if(!B&&!W){v[L]=void 0;continue}if(!W||B&&Q.oldPos<Z.oldPos?O=this.addToPath(Z,!0,!1,0,u):O=this.addToPath(Q,!1,!0,1,u),C=this.extractCommon(O,a,l,L,u),O.oldPos+1>=m&&C+1>=h)return f(this.buildValues(O.lastComponent,a,l))||!0;v[L]=O,O.oldPos+1>=m&&(M=Math.min(M,L-1)),C+1>=h&&(j=Math.max(j,L+1))}p++};if(s)(function L(){setTimeout(function(){if(p>y||Date.now()>S)return s(void 0);A()||L()},0)})();else for(;p<=y&&Date.now()<=S;){const L=A();if(L)return L}}addToPath(l,a,u,s,o){const f=l.lastComponent;return f&&!o.oneChangePerToken&&f.added===a&&f.removed===u?{oldPos:l.oldPos+s,lastComponent:{count:f.count+1,added:a,removed:u,previousComponent:f.previousComponent}}:{oldPos:l.oldPos+s,lastComponent:{count:1,added:a,removed:u,previousComponent:f}}}extractCommon(l,a,u,s,o){const f=a.length,h=u.length;let m=l.oldPos,p=m-s,y=0;for(;p+1<f&&m+1<h&&this.equals(u[m+1],a[p+1],o);)p++,m++,y++,o.oneChangePerToken&&(l.lastComponent={count:1,previousComponent:l.lastComponent,added:!1,removed:!1});return y&&!o.oneChangePerToken&&(l.lastComponent={count:y,previousComponent:l.lastComponent,added:!1,removed:!1}),l.oldPos=m,p}equals(l,a,u){return u.comparator?u.comparator(l,a):l===a||!!u.ignoreCase&&l.toLowerCase()===a.toLowerCase()}removeEmpty(l){const a=[];for(let u=0;u<l.length;u++)l[u]&&a.push(l[u]);return a}castInput(l,a){return l}tokenize(l,a){return Array.from(l)}join(l){return l.join("")}postProcess(l,a){return l}get useLongestToken(){return!1}buildValues(l,a,u){const s=[];let o;for(;l;)s.push(l),o=l.previousComponent,delete l.previousComponent,l=o;s.reverse();const f=s.length;let h=0,m=0,p=0;for(;h<f;h++){const y=s[h];if(y.removed)y.value=this.join(u.slice(p,p+y.count)),p+=y.count;else{if(!y.added&&this.useLongestToken){let g=a.slice(m,m+y.count);g=g.map(function(S,v){const C=u[p+v];return C.length>S.length?C:S}),y.value=this.join(g)}else y.value=this.join(a.slice(m,m+y.count));m+=y.count,y.added||(p+=y.count)}}return s}}function Pg(n,l){let a;for(a=0;a<n.length&&a<l.length;a++)if(n[a]!=l[a])return n.slice(0,a);return n.slice(0,a)}function $g(n,l){let a;if(!n||!l||n[n.length-1]!=l[l.length-1])return"";for(a=0;a<n.length&&a<l.length;a++)if(n[n.length-(a+1)]!=l[l.length-(a+1)])return n.slice(-a);return n.slice(-a)}function Pc(n,l,a){if(n.slice(0,l.length)!=l)throw Error(`string ${JSON.stringify(n)} doesn't start with prefix ${JSON.stringify(l)}; this is a bug`);return a+n.slice(l.length)}function $c(n,l,a){if(!l)return n+a;if(n.slice(-l.length)!=l)throw Error(`string ${JSON.stringify(n)} doesn't end with suffix ${JSON.stringify(l)}; this is a bug`);return n.slice(0,-l.length)+a}function Qa(n,l){return Pc(n,l,"")}function Du(n,l){return $c(n,l,"")}function Wg(n,l){return l.slice(0,nT(n,l))}function nT(n,l){let a=0;n.length>l.length&&(a=n.length-l.length);let u=l.length;n.length<l.length&&(u=n.length);const s=Array(u);let o=0;s[0]=0;for(let f=1;f<u;f++){for(l[f]==l[o]?s[f]=s[o]:s[f]=o;o>0&&l[f]!=l[o];)o=s[o];l[f]==l[o]&&o++}o=0;for(let f=a;f<n.length;f++){for(;o>0&&n[f]!=l[o];)o=s[o];n[f]==l[o]&&o++}return o}function Fa(n){let l;for(l=n.length-1;l>=0&&n[l].match(/\s/);l--);return n.substring(l+1)}function pl(n){const l=n.match(/^\s*/);return l?l[0]:""}const e0="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}",lT=new RegExp(`[${e0}]+|\\s+|[^${e0}]`,"ug");class iT extends tT{equals(l,a,u){return u.ignoreCase&&(l=l.toLowerCase(),a=a.toLowerCase()),l.trim()===a.trim()}tokenize(l,a={}){let u;if(a.intlSegmenter){const f=a.intlSegmenter;if(f.resolvedOptions().granularity!="word")throw new Error('The segmenter passed must have a granularity of "word"');u=[];for(const h of Array.from(f.segment(l))){const m=h.segment;u.length&&/\s/.test(u[u.length-1])&&/\s/.test(m)?u[u.length-1]+=m:u.push(m)}}else u=l.match(lT)||[];const s=[];let o=null;return u.forEach(f=>{/\s/.test(f)?o==null?s.push(f):s.push(s.pop()+f):o!=null&&/\s/.test(o)?s[s.length-1]==o?s.push(s.pop()+f):s.push(o+f):s.push(f),o=f}),s}join(l){return l.map((a,u)=>u==0?a:a.replace(/^\s+/,"")).join("")}postProcess(l,a){if(!l||a.oneChangePerToken)return l;let u=null,s=null,o=null;return l.forEach(f=>{f.added?s=f:f.removed?o=f:((s||o)&&t0(u,o,s,f),u=f,s=null,o=null)}),(s||o)&&t0(u,o,s,null),l}}const aT=new iT;function rT(n,l,a){return aT.diff(n,l,a)}function t0(n,l,a,u){if(l&&a){const s=pl(l.value),o=Fa(l.value),f=pl(a.value),h=Fa(a.value);if(n){const m=Pg(s,f);n.value=$c(n.value,f,m),l.value=Qa(l.value,m),a.value=Qa(a.value,m)}if(u){const m=$g(o,h);u.value=Pc(u.value,h,m),l.value=Du(l.value,m),a.value=Du(a.value,m)}}else if(a){if(n){const s=pl(a.value);a.value=a.value.substring(s.length)}if(u){const s=pl(u.value);u.value=u.value.substring(s.length)}}else if(n&&u){const s=pl(u.value),o=pl(l.value),f=Fa(l.value),h=Pg(s,o);l.value=Qa(l.value,h);const m=$g(Qa(s,h),f);l.value=Du(l.value,m),u.value=Pc(u.value,s,m),n.value=$c(n.value,s,s.slice(0,s.length-m.length))}else if(u){const s=pl(u.value),o=Fa(l.value),f=Wg(o,s);l.value=Du(l.value,f)}else if(n){const s=Fa(n.value),o=pl(l.value),f=Wg(s,o);l.value=Qa(l.value,f)}}function uT(n){const l=[];let a=0,u=0;for(const s of n.split(`
95
- `)){if(s.startsWith("diff ")||s.startsWith("index ")||s.startsWith("---")||s.startsWith("+++"))continue;const o=s.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)?$/);if(o){a=parseInt(o[1],10),u=parseInt(o[2],10),l.push({type:"hunk-header",content:s});continue}s.startsWith("+")?l.push({type:"add",content:s.slice(1),newNum:u++}):s.startsWith("-")?l.push({type:"del",content:s.slice(1),oldNum:a++}):s.startsWith(" ")&&l.push({type:"context",content:s.slice(1),oldNum:a++,newNum:u++})}for(let s=0;s<l.length-1;s++)if(l[s].type==="del"&&l[s+1].type==="add"){const o=rT(l[s].content,l[s+1].content);l[s].wordHighlights=o.map(({value:f,added:h,removed:m})=>({value:f,added:h,removed:m})),l[s+1].wordHighlights=o.map(({value:f,added:h,removed:m})=>({value:f,added:h,removed:m}))}return l}function sT({line:n}){return n.wordHighlights?b.jsx("span",{children:n.wordHighlights.map((l,a)=>n.type==="del"?l.added?null:b.jsx("span",{className:l.removed?"bg-red-800/60 rounded-sm":"",children:l.value},a):n.type==="add"?l.removed?null:b.jsx("span",{className:l.added?"bg-green-800/60 rounded-sm":"",children:l.value},a):b.jsx("span",{children:l.value},a))}):b.jsx("span",{children:n.content||" "})}function oT({diff:n}){const l=le.useMemo(()=>uT(n),[n]);return n.trim()?n.includes("Binary files")&&n.includes("differ")?b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-500 text-sm",children:"Binary file — diff not available"}):b.jsx("div",{className:"overflow-auto h-full font-mono text-xs leading-5",children:l.map((a,u)=>{if(a.type==="hunk-header")return b.jsx("div",{className:"px-3 py-1 bg-blue-900/20 text-blue-400 border-y border-neutral-800 select-none",children:a.content},u);const s=a.type==="add"?"bg-green-950/40":a.type==="del"?"bg-red-950/40":"",o=a.type==="add"?"text-green-300":a.type==="del"?"text-red-300":"text-neutral-400";return b.jsxs("div",{className:`flex ${s} hover:brightness-125`,children:[b.jsx("span",{className:"w-12 shrink-0 text-right pr-2 text-neutral-600 select-none border-r border-neutral-800",children:a.oldNum??""}),b.jsx("span",{className:"w-12 shrink-0 text-right pr-2 text-neutral-600 select-none border-r border-neutral-800",children:a.newNum??""}),b.jsx("span",{className:"w-5 shrink-0 text-center select-none text-neutral-600",children:a.type==="add"?"+":a.type==="del"?"-":" "}),b.jsx("span",{className:`flex-1 pr-4 whitespace-pre ${o}`,children:b.jsx(sT,{line:a})})]},u)})}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"No changes"})}function n0(){return""}function cT(n){const l={A:"bg-green-700 text-green-100",M:"bg-amber-700 text-amber-100",D:"bg-red-700 text-red-100"};return b.jsx("span",{className:`text-[10px] font-bold px-1 rounded ${l[n]||"bg-neutral-700 text-neutral-300"}`,children:n})}function fT(){const n=de(g=>g.changedFilesTick),l=de(g=>g.diffBase),a=de(g=>g.setDiffBase),[u,s]=le.useState([]),[o,f]=le.useState(null),[h,m]=le.useState(""),[p,y]=le.useState(!1);return le.useEffect(()=>{const g=n0();fetch(`${g}/api/git/changed-files?base=${l}`).then(S=>S.json()).then(S=>{const v=S.files||[];s(v),v.length>0&&(!o||!v.some(C=>C.path===o))?f(v[0].path):v.length===0&&f(null)}).catch(()=>s([]))},[n,l]),le.useEffect(()=>{if(!o){m("");return}y(!0);const g=n0();fetch(`${g}/api/git/diff?path=${encodeURIComponent(o)}&base=${l}`).then(S=>S.json()).then(S=>m(S.diff||"")).catch(()=>m("")).finally(()=>y(!1))},[o,l,n]),b.jsxs("div",{className:"flex h-full",children:[b.jsxs("div",{className:"w-56 shrink-0 border-r border-neutral-800 flex flex-col",children:[b.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-neutral-800",children:[b.jsxs("span",{className:"text-xs font-medium text-neutral-400",children:["Changed Files (",u.length,")"]}),b.jsx("button",{onClick:()=>a(l==="last-commit"?"default-branch":"last-commit"),className:"text-[10px] px-1.5 py-0.5 rounded bg-neutral-800 text-neutral-400 hover:text-neutral-200",title:`Diff base: ${l}`,children:l==="last-commit"?"HEAD":"branch"})]}),b.jsx("div",{className:"flex-1 overflow-auto",children:u.length===0?b.jsx("div",{className:"px-3 py-8 text-center text-neutral-600 text-xs",children:"No changes"}):u.map(g=>b.jsxs("button",{onClick:()=>f(g.path),className:`w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs hover:bg-neutral-800/50 ${o===g.path?"bg-neutral-800 text-neutral-100":"text-neutral-400"}`,children:[cT(g.status),b.jsx("span",{className:"truncate",children:g.path})]},g.path))})]}),b.jsx("div",{className:"flex-1 min-w-0",children:p?b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Loading..."}):o?b.jsx(oT,{diff:h}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Select a file to view diff"})})]})}function dT(){return""}function hT(n){const l=Math.floor(n/1e3);if(l<60)return`${l}s`;const a=Math.floor(l/60);return a<60?`${a}m ${l%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function l0({proc:n,onKill:l}){const[a,u]=le.useState(Date.now()-n.startedAt);le.useEffect(()=>{if(n.status!=="running")return;const o=setInterval(()=>u(Date.now()-n.startedAt),1e3);return()=>clearInterval(o)},[n.status,n.startedAt]);const s={running:"text-amber-400",completed:"text-green-400",failed:"text-red-400",stopped:"text-neutral-500"};return b.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-neutral-800/30 text-xs",children:[b.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n.status==="running"?"bg-amber-400 animate-pulse":n.status==="completed"?"bg-green-400":n.status==="failed"?"bg-red-400":"bg-neutral-600"}`}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("div",{className:"text-neutral-200 truncate",children:n.description||n.command}),b.jsx("div",{className:"text-neutral-500 truncate font-mono",children:n.command})]}),b.jsx("span",{className:`shrink-0 ${s[n.status]||"text-neutral-500"}`,children:n.status==="running"?hT(a):n.status}),n.status==="running"&&b.jsx("button",{onClick:l,className:"shrink-0 text-red-400 hover:text-red-300 px-1",children:"Kill"})]})}function mT({proc:n,onKill:l}){return b.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-neutral-800/30 text-xs",children:[b.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("div",{className:"text-neutral-200 truncate",children:n.command}),b.jsx("div",{className:"text-neutral-500 truncate font-mono",children:n.fullCommand}),n.cwd&&b.jsx("div",{className:"text-neutral-600 truncate",children:n.cwd})]}),b.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n.ports.map(a=>b.jsxs("a",{href:`http://localhost:${a}`,target:"_blank",rel:"noopener",className:"text-blue-400 hover:text-blue-300",children:[":",a]},a)),b.jsxs("span",{className:"text-neutral-600",children:["PID ",n.pid]}),b.jsx("button",{onClick:l,className:"text-red-400 hover:text-red-300 px-1",children:"Kill"})]})]})}function pT(){const n=de(g=>g.sessionProcesses),[l,a]=le.useState([]),[u,s]=le.useState(!1),o=dT(),f=()=>{s(!0),fetch(`${o}/api/processes/system`).then(g=>g.json()).then(g=>a(g.processes||[])).catch(()=>{}).finally(()=>s(!1))};le.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[]);const h=g=>{fetch(`${o}/api/processes/${encodeURIComponent(g)}/kill`,{method:"POST"}).catch(()=>{}),setTimeout(()=>{de.getState().updateProcess(g,{status:"stopped",completedAt:Date.now()})},3e3)},m=g=>{fetch(`${o}/api/processes/system/${g}/kill`,{method:"POST"}).catch(()=>{}),setTimeout(()=>a(S=>S.filter(v=>v.pid!==g)),1e3)},p=n.filter(g=>g.status==="running"),y=n.filter(g=>g.status!=="running");return b.jsxs("div",{className:"flex flex-col h-full overflow-auto",children:[n.length>0&&b.jsxs("div",{className:"border-b border-neutral-800",children:[b.jsxs("div",{className:"px-3 py-2 text-xs font-medium text-neutral-400",children:["Background Jobs (",n.length,")"]}),p.map(g=>b.jsx(l0,{proc:g,onKill:()=>h(g.taskId)},g.taskId)),y.map(g=>b.jsx(l0,{proc:g,onKill:()=>{}},g.taskId))]}),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[b.jsxs("span",{className:"text-xs font-medium text-neutral-400",children:["Dev Servers (",l.length,")"]}),b.jsx("button",{onClick:f,disabled:u,className:"text-[10px] px-1.5 py-0.5 rounded bg-neutral-800 text-neutral-400 hover:text-neutral-200",children:u?"Scanning...":"Scan"})]}),l.length===0?b.jsx("div",{className:"px-3 py-6 text-center text-neutral-600 text-xs",children:u?"Scanning for dev servers...":"No dev servers found"}):l.map(g=>b.jsx(mT,{proc:g,onKill:()=>m(g.pid)},g.pid))]})]})}function gT(){return""}function yT(){const n=de(l=>l.session);return n?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Session"}),b.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs",children:[b.jsx("span",{className:"text-neutral-500",children:"Model"}),b.jsx("span",{className:"text-neutral-200 truncate",children:n.model||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Version"}),b.jsx("span",{className:"text-neutral-200 truncate",children:n.claude_code_version||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Working dir"}),b.jsx("span",{className:"text-neutral-200 truncate",title:n.cwd,children:n.cwd||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Cost"}),b.jsxs("span",{className:"text-neutral-200",children:["$",n.total_cost_usd.toFixed(4)]}),b.jsx("span",{className:"text-neutral-500",children:"Turns"}),b.jsx("span",{className:"text-neutral-200",children:n.num_turns}),b.jsx("span",{className:"text-neutral-500",children:"Lines"}),b.jsxs("span",{className:"text-neutral-200",children:[b.jsxs("span",{className:"text-green-400",children:["+",n.total_lines_added]})," / ",b.jsxs("span",{className:"text-red-400",children:["-",n.total_lines_removed]})]})]})]}):null}function xT({status:n}){switch(n){case"completed":return b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-green-400 shrink-0",children:b.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 108 0a8 8 0 000 16zm3.78-9.72a.75.75 0 00-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.06 0l4.25-4.25z",clipRule:"evenodd"})});case"in_progress":return b.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",className:"w-3.5 h-3.5 text-blue-400 shrink-0 animate-spin",children:b.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"1.5",strokeDasharray:"28 10"})});default:return b.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",className:"w-3.5 h-3.5 text-neutral-500 shrink-0",children:b.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"1.5"})})}}function bT(){const n=de(a=>a.tasks),l=n.filter(a=>a.status==="completed").length;return b.jsxs("section",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Tasks"}),n.length>0&&b.jsxs("span",{className:"text-[10px] text-neutral-500 bg-neutral-800 px-1.5 py-0.5 rounded-full",children:[l,"/",n.length]})]}),n.length===0?b.jsx("p",{className:"text-xs text-neutral-600",children:"No tasks yet"}):b.jsx("ul",{className:"space-y-1.5",children:n.map(a=>b.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[b.jsx("div",{className:"mt-0.5",children:b.jsx(xT,{status:a.status})}),b.jsxs("div",{className:"min-w-0 flex-1",children:[b.jsx("span",{className:a.status==="completed"?"text-neutral-500 line-through":"text-neutral-200",children:a.status==="in_progress"&&a.activeForm?b.jsx("span",{className:"italic",children:a.activeForm}):a.subject}),a.blockedBy&&a.blockedBy.length>0&&a.status!=="completed"&&b.jsx("span",{className:"ml-1.5 text-[10px] text-amber-500",children:"blocked"})]})]},a.id))})]})}function vT(n){switch(n){case"connected":return"bg-green-400";case"connecting":return"bg-amber-400";case"error":case"disconnected":return"bg-red-400";default:return"bg-neutral-500"}}function ST(){const n=de(l=>{var a;return(a=l.session)==null?void 0:a.mcp_servers});return n!=null&&n.length?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"MCP Servers"}),b.jsx("ul",{className:"space-y-1",children:n.map(l=>b.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[b.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${vT(l.status)}`}),b.jsx("span",{className:"text-neutral-200 truncate",children:l.name}),b.jsx("span",{className:"text-neutral-600 ml-auto shrink-0",children:l.status})]},l.name))})]}):null}function kT(){const n=de(o=>{var f;return(f=o.session)==null?void 0:f.tools}),[l,a]=le.useState(!1);if(!(n!=null&&n.length))return null;const u=l?n:n.slice(0,8),s=n.length>8;return b.jsxs("section",{className:"space-y-2",children:[b.jsxs("button",{onClick:()=>a(o=>!o),className:"flex items-center gap-1 text-xs font-semibold text-neutral-400 uppercase tracking-wider hover:text-neutral-300 transition-colors",children:[b.jsxs("span",{children:["Tools (",n.length,")"]}),b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 transition-transform ${l?"rotate-90":""}`,children:b.jsx("path",{d:"M6 4l4 4-4 4"})})]}),b.jsx("ul",{className:"space-y-0.5",children:u.map(o=>b.jsx("li",{className:"text-xs text-neutral-400 truncate pl-1",children:o},o))}),s&&!l&&b.jsxs("button",{onClick:()=>a(!0),className:"text-xs text-neutral-600 hover:text-neutral-400 transition-colors",children:["+",n.length-8," more..."]})]})}function wT(){const n=de(u=>u.gitAvailable),[l,a]=le.useState(null);return le.useEffect(()=>{n!==!1&&fetch(`${gT()}/api/git/info`).then(u=>u.json()).then(a).catch(()=>{})},[n]),l!=null&&l.branch?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Git"}),b.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-neutral-500 shrink-0",children:b.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"})}),b.jsx("span",{className:"text-neutral-200 font-mono",children:l.branch}),(l.ahead>0||l.behind>0)&&b.jsxs("span",{className:"text-neutral-500",children:[l.ahead>0&&b.jsxs("span",{className:"text-green-400",children:["↑",l.ahead]}),l.ahead>0&&l.behind>0&&" ",l.behind>0&&b.jsxs("span",{className:"text-red-400",children:["↓",l.behind]})]})]})]}):null}function CT(){return de(l=>l.session)?b.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-4 space-y-5",children:[b.jsx(yT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(bT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(ST,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(kT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(wT,{})]}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"No active session"})}const i0={doc:{type:"builtin",manifestLoader:()=>Li(()=>import("./manifest-D0B-XRFy.js"),[]).then(n=>n.default),definitionLoader:()=>Li(()=>import("./pneuma-mode-r4_sojXe.js"),__vite__mapDeps([0,1])).then(n=>n.default)},slide:{type:"builtin",manifestLoader:()=>Li(()=>import("./manifest-CYNgEFXq.js"),[]).then(n=>n.default),definitionLoader:()=>Li(()=>import("./pneuma-mode-CjWVuMga.js"),__vite__mapDeps([2,3])).then(n=>n.default)}};async function ET(n){const l=TT(n);return await zT(l),AT(l)}function TT(n){const l=i0[n];if(!l){const a=Object.keys(i0).join(", ");throw new Error(`Unknown mode: "${n}". Available: ${a}`)}return l}async function zT(n){n.type}async function AT(n){if(n.type==="builtin")return n.definitionLoader();throw new Error("Non-builtin mode loading not yet implemented")}const jT=le.lazy(()=>Li(()=>import("./EditorPanel-Dc5ZKGWZ.js"),[])),NT=le.lazy(()=>Li(()=>import("./TerminalPanel-DlXrAk_5.js"),__vite__mapDeps([4,5])));function Wc(){return b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Loading..."})}function _T(){const n=de(u=>u.activeTab),[l,a]=le.useState(!1);return le.useEffect(()=>{n==="terminal"&&a(!0)},[n]),b.jsxs("div",{className:"flex flex-col h-full",children:[n==="chat"&&b.jsx(eT,{}),n==="editor"&&b.jsx(le.Suspense,{fallback:b.jsx(Wc,{}),children:b.jsx(jT,{})}),n==="diff"&&b.jsx(fT,{}),l&&b.jsx(le.Suspense,{fallback:n==="terminal"?b.jsx(Wc,{}):null,children:b.jsx("div",{className:n==="terminal"?"flex flex-col h-full":"hidden",children:b.jsx(NT,{})})}),n==="processes"&&b.jsx(pT,{}),n==="context"&&b.jsx(CT,{})]})}function DT(){const n=de(h=>h.files),l=de(h=>h.selection),a=de(h=>h.setSelection),u=de(h=>h.previewMode),s=de(h=>h.imageTick),o=de(h=>h.initParams),f=de(h=>h.setActiveFile);return{files:n.map(h=>({path:h.path,content:h.content})),selection:l?{type:l.type,content:l.content,level:l.level}:null,onSelect:h=>{var p;if(!h){a(null);return}const m=h.file||((p=n[0])==null?void 0:p.path)||"";a({type:h.type,content:h.content,level:h.level,file:m})},mode:u,imageVersion:s,initParams:o,onActiveFileChange:f}}function Mu(){return""}function MT(){const n=de(a=>{var u;return(u=a.modeViewer)==null?void 0:u.PreviewComponent});le.useEffect(()=>{const a=new URLSearchParams(location.search),u=a.get("session"),s=a.get("mode")||"doc";ET(s).then(o=>{de.getState().setModeViewer(o.viewer)}).catch(o=>{console.error(`[app] Failed to load mode "${s}":`,o)}),u?Lu(u):fetch(`${Mu()}/api/session`).then(o=>o.json()).then(o=>{Lu(o.sessionId||"default")}).catch(()=>Lu("default")),fetch(`${Mu()}/api/files`).then(o=>o.json()).then(o=>{var f;(f=o.files)!=null&&f.length&&de.getState().setFiles(o.files)}).catch(()=>{}),fetch(`${Mu()}/api/config`).then(o=>o.json()).then(o=>{o.initParams&&de.getState().setInitParams(o.initParams)}).catch(()=>{}),fetch(`${Mu()}/api/git/available`).then(o=>o.json()).then(o=>de.getState().setGitAvailable(o.available)).catch(()=>de.getState().setGitAvailable(!1))},[]);const l=DT();return b.jsxs("div",{className:"flex flex-col h-screen bg-neutral-950 text-neutral-100",children:[b.jsx(Qb,{}),b.jsxs(x0,{orientation:"horizontal",className:"flex-1",children:[b.jsx(Bc,{defaultSize:55,minSize:30,children:n?b.jsx(n,{...l}):b.jsx(Wc,{})}),b.jsx(b0,{className:"w-1 bg-neutral-800 hover:bg-neutral-700 transition-colors"}),b.jsx(Bc,{defaultSize:45,minSize:25,children:b.jsx(_T,{})})]})]})}tb.createRoot(document.getElementById("root")).render(b.jsx(le.StrictMode,{children:b.jsx(MT,{})}));export{ty as M,Cu as R,LT as a,Fb as b,sv as c,ff as d,z0 as e,iv as f,Hu as g,uv as h,Ey as i,b as j,$1 as k,Uc as n,RT as o,BT as p,le as r,cf as s,de as u,kf as v};
95
+ `)){if(s.startsWith("diff ")||s.startsWith("index ")||s.startsWith("---")||s.startsWith("+++"))continue;const o=s.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@(.*)?$/);if(o){a=parseInt(o[1],10),u=parseInt(o[2],10),l.push({type:"hunk-header",content:s});continue}s.startsWith("+")?l.push({type:"add",content:s.slice(1),newNum:u++}):s.startsWith("-")?l.push({type:"del",content:s.slice(1),oldNum:a++}):s.startsWith(" ")&&l.push({type:"context",content:s.slice(1),oldNum:a++,newNum:u++})}for(let s=0;s<l.length-1;s++)if(l[s].type==="del"&&l[s+1].type==="add"){const o=rT(l[s].content,l[s+1].content);l[s].wordHighlights=o.map(({value:f,added:h,removed:m})=>({value:f,added:h,removed:m})),l[s+1].wordHighlights=o.map(({value:f,added:h,removed:m})=>({value:f,added:h,removed:m}))}return l}function sT({line:n}){return n.wordHighlights?b.jsx("span",{children:n.wordHighlights.map((l,a)=>n.type==="del"?l.added?null:b.jsx("span",{className:l.removed?"bg-red-800/60 rounded-sm":"",children:l.value},a):n.type==="add"?l.removed?null:b.jsx("span",{className:l.added?"bg-green-800/60 rounded-sm":"",children:l.value},a):b.jsx("span",{children:l.value},a))}):b.jsx("span",{children:n.content||" "})}function oT({diff:n}){const l=le.useMemo(()=>uT(n),[n]);return n.trim()?n.includes("Binary files")&&n.includes("differ")?b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-500 text-sm",children:"Binary file — diff not available"}):b.jsx("div",{className:"overflow-auto h-full font-mono text-xs leading-5",children:l.map((a,u)=>{if(a.type==="hunk-header")return b.jsx("div",{className:"px-3 py-1 bg-blue-900/20 text-blue-400 border-y border-neutral-800 select-none",children:a.content},u);const s=a.type==="add"?"bg-green-950/40":a.type==="del"?"bg-red-950/40":"",o=a.type==="add"?"text-green-300":a.type==="del"?"text-red-300":"text-neutral-400";return b.jsxs("div",{className:`flex ${s} hover:brightness-125`,children:[b.jsx("span",{className:"w-12 shrink-0 text-right pr-2 text-neutral-600 select-none border-r border-neutral-800",children:a.oldNum??""}),b.jsx("span",{className:"w-12 shrink-0 text-right pr-2 text-neutral-600 select-none border-r border-neutral-800",children:a.newNum??""}),b.jsx("span",{className:"w-5 shrink-0 text-center select-none text-neutral-600",children:a.type==="add"?"+":a.type==="del"?"-":" "}),b.jsx("span",{className:`flex-1 pr-4 whitespace-pre ${o}`,children:b.jsx(sT,{line:a})})]},u)})}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"No changes"})}function n0(){return""}function cT(n){const l={A:"bg-green-700 text-green-100",M:"bg-amber-700 text-amber-100",D:"bg-red-700 text-red-100"};return b.jsx("span",{className:`text-[10px] font-bold px-1 rounded ${l[n]||"bg-neutral-700 text-neutral-300"}`,children:n})}function fT(){const n=de(g=>g.changedFilesTick),l=de(g=>g.diffBase),a=de(g=>g.setDiffBase),[u,s]=le.useState([]),[o,f]=le.useState(null),[h,m]=le.useState(""),[p,y]=le.useState(!1);return le.useEffect(()=>{const g=n0();fetch(`${g}/api/git/changed-files?base=${l}`).then(S=>S.json()).then(S=>{const v=S.files||[];s(v),v.length>0&&(!o||!v.some(C=>C.path===o))?f(v[0].path):v.length===0&&f(null)}).catch(()=>s([]))},[n,l]),le.useEffect(()=>{if(!o){m("");return}y(!0);const g=n0();fetch(`${g}/api/git/diff?path=${encodeURIComponent(o)}&base=${l}`).then(S=>S.json()).then(S=>m(S.diff||"")).catch(()=>m("")).finally(()=>y(!1))},[o,l,n]),b.jsxs("div",{className:"flex h-full",children:[b.jsxs("div",{className:"w-56 shrink-0 border-r border-neutral-800 flex flex-col",children:[b.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-neutral-800",children:[b.jsxs("span",{className:"text-xs font-medium text-neutral-400",children:["Changed Files (",u.length,")"]}),b.jsx("button",{onClick:()=>a(l==="last-commit"?"default-branch":"last-commit"),className:"text-[10px] px-1.5 py-0.5 rounded bg-neutral-800 text-neutral-400 hover:text-neutral-200",title:`Diff base: ${l}`,children:l==="last-commit"?"HEAD":"branch"})]}),b.jsx("div",{className:"flex-1 overflow-auto",children:u.length===0?b.jsx("div",{className:"px-3 py-8 text-center text-neutral-600 text-xs",children:"No changes"}):u.map(g=>b.jsxs("button",{onClick:()=>f(g.path),className:`w-full text-left px-3 py-1.5 flex items-center gap-2 text-xs hover:bg-neutral-800/50 ${o===g.path?"bg-neutral-800 text-neutral-100":"text-neutral-400"}`,children:[cT(g.status),b.jsx("span",{className:"truncate",children:g.path})]},g.path))})]}),b.jsx("div",{className:"flex-1 min-w-0",children:p?b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Loading..."}):o?b.jsx(oT,{diff:h}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Select a file to view diff"})})]})}function dT(){return""}function hT(n){const l=Math.floor(n/1e3);if(l<60)return`${l}s`;const a=Math.floor(l/60);return a<60?`${a}m ${l%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function l0({proc:n,onKill:l}){const[a,u]=le.useState(Date.now()-n.startedAt);le.useEffect(()=>{if(n.status!=="running")return;const o=setInterval(()=>u(Date.now()-n.startedAt),1e3);return()=>clearInterval(o)},[n.status,n.startedAt]);const s={running:"text-amber-400",completed:"text-green-400",failed:"text-red-400",stopped:"text-neutral-500"};return b.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-neutral-800/30 text-xs",children:[b.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n.status==="running"?"bg-amber-400 animate-pulse":n.status==="completed"?"bg-green-400":n.status==="failed"?"bg-red-400":"bg-neutral-600"}`}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("div",{className:"text-neutral-200 truncate",children:n.description||n.command}),b.jsx("div",{className:"text-neutral-500 truncate font-mono",children:n.command})]}),b.jsx("span",{className:`shrink-0 ${s[n.status]||"text-neutral-500"}`,children:n.status==="running"?hT(a):n.status}),n.status==="running"&&b.jsx("button",{onClick:l,className:"shrink-0 text-red-400 hover:text-red-300 px-1",children:"Kill"})]})}function mT({proc:n,onKill:l}){return b.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-neutral-800/30 text-xs",children:[b.jsx("span",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("div",{className:"text-neutral-200 truncate",children:n.command}),b.jsx("div",{className:"text-neutral-500 truncate font-mono",children:n.fullCommand}),n.cwd&&b.jsx("div",{className:"text-neutral-600 truncate",children:n.cwd})]}),b.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n.ports.map(a=>b.jsxs("a",{href:`http://localhost:${a}`,target:"_blank",rel:"noopener",className:"text-blue-400 hover:text-blue-300",children:[":",a]},a)),b.jsxs("span",{className:"text-neutral-600",children:["PID ",n.pid]}),b.jsx("button",{onClick:l,className:"text-red-400 hover:text-red-300 px-1",children:"Kill"})]})]})}function pT(){const n=de(g=>g.sessionProcesses),[l,a]=le.useState([]),[u,s]=le.useState(!1),o=dT(),f=()=>{s(!0),fetch(`${o}/api/processes/system`).then(g=>g.json()).then(g=>a(g.processes||[])).catch(()=>{}).finally(()=>s(!1))};le.useEffect(()=>{f();const g=setInterval(f,15e3);return()=>clearInterval(g)},[]);const h=g=>{fetch(`${o}/api/processes/${encodeURIComponent(g)}/kill`,{method:"POST"}).catch(()=>{}),setTimeout(()=>{de.getState().updateProcess(g,{status:"stopped",completedAt:Date.now()})},3e3)},m=g=>{fetch(`${o}/api/processes/system/${g}/kill`,{method:"POST"}).catch(()=>{}),setTimeout(()=>a(S=>S.filter(v=>v.pid!==g)),1e3)},p=n.filter(g=>g.status==="running"),y=n.filter(g=>g.status!=="running");return b.jsxs("div",{className:"flex flex-col h-full overflow-auto",children:[n.length>0&&b.jsxs("div",{className:"border-b border-neutral-800",children:[b.jsxs("div",{className:"px-3 py-2 text-xs font-medium text-neutral-400",children:["Background Jobs (",n.length,")"]}),p.map(g=>b.jsx(l0,{proc:g,onKill:()=>h(g.taskId)},g.taskId)),y.map(g=>b.jsx(l0,{proc:g,onKill:()=>{}},g.taskId))]}),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[b.jsxs("span",{className:"text-xs font-medium text-neutral-400",children:["Dev Servers (",l.length,")"]}),b.jsx("button",{onClick:f,disabled:u,className:"text-[10px] px-1.5 py-0.5 rounded bg-neutral-800 text-neutral-400 hover:text-neutral-200",children:u?"Scanning...":"Scan"})]}),l.length===0?b.jsx("div",{className:"px-3 py-6 text-center text-neutral-600 text-xs",children:u?"Scanning for dev servers...":"No dev servers found"}):l.map(g=>b.jsx(mT,{proc:g,onKill:()=>m(g.pid)},g.pid))]})]})}function gT(){return""}function yT(){const n=de(l=>l.session);return n?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Session"}),b.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs",children:[b.jsx("span",{className:"text-neutral-500",children:"Model"}),b.jsx("span",{className:"text-neutral-200 truncate",children:n.model||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Version"}),b.jsx("span",{className:"text-neutral-200 truncate",children:n.claude_code_version||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Working dir"}),b.jsx("span",{className:"text-neutral-200 truncate",title:n.cwd,children:n.cwd||"—"}),b.jsx("span",{className:"text-neutral-500",children:"Cost"}),b.jsxs("span",{className:"text-neutral-200",children:["$",n.total_cost_usd.toFixed(4)]}),b.jsx("span",{className:"text-neutral-500",children:"Turns"}),b.jsx("span",{className:"text-neutral-200",children:n.num_turns}),b.jsx("span",{className:"text-neutral-500",children:"Lines"}),b.jsxs("span",{className:"text-neutral-200",children:[b.jsxs("span",{className:"text-green-400",children:["+",n.total_lines_added]})," / ",b.jsxs("span",{className:"text-red-400",children:["-",n.total_lines_removed]})]})]})]}):null}function xT({status:n}){switch(n){case"completed":return b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-green-400 shrink-0",children:b.jsx("path",{fillRule:"evenodd",d:"M8 16A8 8 0 108 0a8 8 0 000 16zm3.78-9.72a.75.75 0 00-1.06-1.06L7 8.94 5.28 7.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.06 0l4.25-4.25z",clipRule:"evenodd"})});case"in_progress":return b.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",className:"w-3.5 h-3.5 text-blue-400 shrink-0 animate-spin",children:b.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"1.5",strokeDasharray:"28 10"})});default:return b.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",className:"w-3.5 h-3.5 text-neutral-500 shrink-0",children:b.jsx("circle",{cx:"8",cy:"8",r:"6",strokeWidth:"1.5"})})}}function bT(){const n=de(a=>a.tasks),l=n.filter(a=>a.status==="completed").length;return b.jsxs("section",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Tasks"}),n.length>0&&b.jsxs("span",{className:"text-[10px] text-neutral-500 bg-neutral-800 px-1.5 py-0.5 rounded-full",children:[l,"/",n.length]})]}),n.length===0?b.jsx("p",{className:"text-xs text-neutral-600",children:"No tasks yet"}):b.jsx("ul",{className:"space-y-1.5",children:n.map(a=>b.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[b.jsx("div",{className:"mt-0.5",children:b.jsx(xT,{status:a.status})}),b.jsxs("div",{className:"min-w-0 flex-1",children:[b.jsx("span",{className:a.status==="completed"?"text-neutral-500 line-through":"text-neutral-200",children:a.status==="in_progress"&&a.activeForm?b.jsx("span",{className:"italic",children:a.activeForm}):a.subject}),a.blockedBy&&a.blockedBy.length>0&&a.status!=="completed"&&b.jsx("span",{className:"ml-1.5 text-[10px] text-amber-500",children:"blocked"})]})]},a.id))})]})}function vT(n){switch(n){case"connected":return"bg-green-400";case"connecting":return"bg-amber-400";case"error":case"disconnected":return"bg-red-400";default:return"bg-neutral-500"}}function ST(){const n=de(l=>{var a;return(a=l.session)==null?void 0:a.mcp_servers});return n!=null&&n.length?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"MCP Servers"}),b.jsx("ul",{className:"space-y-1",children:n.map(l=>b.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[b.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${vT(l.status)}`}),b.jsx("span",{className:"text-neutral-200 truncate",children:l.name}),b.jsx("span",{className:"text-neutral-600 ml-auto shrink-0",children:l.status})]},l.name))})]}):null}function kT(){const n=de(o=>{var f;return(f=o.session)==null?void 0:f.tools}),[l,a]=le.useState(!1);if(!(n!=null&&n.length))return null;const u=l?n:n.slice(0,8),s=n.length>8;return b.jsxs("section",{className:"space-y-2",children:[b.jsxs("button",{onClick:()=>a(o=>!o),className:"flex items-center gap-1 text-xs font-semibold text-neutral-400 uppercase tracking-wider hover:text-neutral-300 transition-colors",children:[b.jsxs("span",{children:["Tools (",n.length,")"]}),b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:`w-3 h-3 transition-transform ${l?"rotate-90":""}`,children:b.jsx("path",{d:"M6 4l4 4-4 4"})})]}),b.jsx("ul",{className:"space-y-0.5",children:u.map(o=>b.jsx("li",{className:"text-xs text-neutral-400 truncate pl-1",children:o},o))}),s&&!l&&b.jsxs("button",{onClick:()=>a(!0),className:"text-xs text-neutral-600 hover:text-neutral-400 transition-colors",children:["+",n.length-8," more..."]})]})}function wT(){const n=de(u=>u.gitAvailable),[l,a]=le.useState(null);return le.useEffect(()=>{n!==!1&&fetch(`${gT()}/api/git/info`).then(u=>u.json()).then(a).catch(()=>{})},[n]),l!=null&&l.branch?b.jsxs("section",{className:"space-y-2",children:[b.jsx("h3",{className:"text-xs font-semibold text-neutral-400 uppercase tracking-wider",children:"Git"}),b.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[b.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5 text-neutral-500 shrink-0",children:b.jsx("path",{d:"M11.75 2.5a.75.75 0 100 1.5.75.75 0 000-1.5zm-2.25.75a2.25 2.25 0 113 2.122V6A2.5 2.5 0 0110 8.5H6a1 1 0 00-1 1v1.128a2.251 2.251 0 11-1.5 0V5.372a2.25 2.25 0 111.5 0v1.836A2.492 2.492 0 016 7h4a1 1 0 001-1v-.628A2.25 2.25 0 019.5 3.25zM4.25 12a.75.75 0 100 1.5.75.75 0 000-1.5zM3.5 3.25a.75.75 0 111.5 0 .75.75 0 01-1.5 0z"})}),b.jsx("span",{className:"text-neutral-200 font-mono",children:l.branch}),(l.ahead>0||l.behind>0)&&b.jsxs("span",{className:"text-neutral-500",children:[l.ahead>0&&b.jsxs("span",{className:"text-green-400",children:["↑",l.ahead]}),l.ahead>0&&l.behind>0&&" ",l.behind>0&&b.jsxs("span",{className:"text-red-400",children:["↓",l.behind]})]})]})]}):null}function CT(){return de(l=>l.session)?b.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-4 space-y-5",children:[b.jsx(yT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(bT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(ST,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(kT,{}),b.jsx("div",{className:"border-t border-neutral-800"}),b.jsx(wT,{})]}):b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"No active session"})}const i0={doc:{type:"builtin",manifestLoader:()=>Li(()=>import("./manifest-D0B-XRFy.js"),[]).then(n=>n.default),definitionLoader:()=>Li(()=>import("./pneuma-mode-C4v13scm.js"),__vite__mapDeps([0,1])).then(n=>n.default)},slide:{type:"builtin",manifestLoader:()=>Li(()=>import("./manifest-DGD2_XYa.js"),[]).then(n=>n.default),definitionLoader:()=>Li(()=>import("./pneuma-mode-_Ng_oSnc.js"),__vite__mapDeps([2,3])).then(n=>n.default)}};async function ET(n){const l=TT(n);return await zT(l),AT(l)}function TT(n){const l=i0[n];if(!l){const a=Object.keys(i0).join(", ");throw new Error(`Unknown mode: "${n}". Available: ${a}`)}return l}async function zT(n){n.type}async function AT(n){if(n.type==="builtin")return n.definitionLoader();throw new Error("Non-builtin mode loading not yet implemented")}const jT=le.lazy(()=>Li(()=>import("./EditorPanel-JzFuk3WG.js"),[])),NT=le.lazy(()=>Li(()=>import("./TerminalPanel-xx5i__-P.js"),__vite__mapDeps([4,5])));function Wc(){return b.jsx("div",{className:"flex items-center justify-center h-full text-neutral-600 text-sm",children:"Loading..."})}function _T(){const n=de(u=>u.activeTab),[l,a]=le.useState(!1);return le.useEffect(()=>{n==="terminal"&&a(!0)},[n]),b.jsxs("div",{className:"flex flex-col h-full",children:[n==="chat"&&b.jsx(eT,{}),n==="editor"&&b.jsx(le.Suspense,{fallback:b.jsx(Wc,{}),children:b.jsx(jT,{})}),n==="diff"&&b.jsx(fT,{}),l&&b.jsx(le.Suspense,{fallback:n==="terminal"?b.jsx(Wc,{}):null,children:b.jsx("div",{className:n==="terminal"?"flex flex-col h-full":"hidden",children:b.jsx(NT,{})})}),n==="processes"&&b.jsx(pT,{}),n==="context"&&b.jsx(CT,{})]})}function DT(){const n=de(h=>h.files),l=de(h=>h.selection),a=de(h=>h.setSelection),u=de(h=>h.previewMode),s=de(h=>h.imageTick),o=de(h=>h.initParams),f=de(h=>h.setActiveFile);return{files:n.map(h=>({path:h.path,content:h.content})),selection:l?{type:l.type,content:l.content,level:l.level}:null,onSelect:h=>{var p;if(!h){a(null);return}const m=h.file||((p=n[0])==null?void 0:p.path)||"";a({type:h.type,content:h.content,level:h.level,file:m})},mode:u,imageVersion:s,initParams:o,onActiveFileChange:f}}function Mu(){return""}function MT(){const n=de(a=>{var u;return(u=a.modeViewer)==null?void 0:u.PreviewComponent});le.useEffect(()=>{const a=new URLSearchParams(location.search),u=a.get("session"),s=a.get("mode")||"doc";ET(s).then(o=>{de.getState().setModeViewer(o.viewer)}).catch(o=>{console.error(`[app] Failed to load mode "${s}":`,o)}),u?Lu(u):fetch(`${Mu()}/api/session`).then(o=>o.json()).then(o=>{Lu(o.sessionId||"default")}).catch(()=>Lu("default")),fetch(`${Mu()}/api/files`).then(o=>o.json()).then(o=>{var f;(f=o.files)!=null&&f.length&&de.getState().setFiles(o.files)}).catch(()=>{}),fetch(`${Mu()}/api/config`).then(o=>o.json()).then(o=>{o.initParams&&de.getState().setInitParams(o.initParams)}).catch(()=>{}),fetch(`${Mu()}/api/git/available`).then(o=>o.json()).then(o=>de.getState().setGitAvailable(o.available)).catch(()=>de.getState().setGitAvailable(!1))},[]);const l=DT();return b.jsxs("div",{className:"flex flex-col h-screen bg-neutral-950 text-neutral-100",children:[b.jsx(Qb,{}),b.jsxs(x0,{orientation:"horizontal",className:"flex-1",children:[b.jsx(Bc,{defaultSize:60,minSize:30,children:n?b.jsx(n,{...l}):b.jsx(Wc,{})}),b.jsx(b0,{className:"w-1 bg-neutral-800 hover:bg-neutral-700 transition-colors"}),b.jsx(Bc,{defaultSize:40,minSize:25,children:b.jsx(_T,{})})]})]})}tb.createRoot(document.getElementById("root")).render(b.jsx(le.StrictMode,{children:b.jsx(MT,{})}));export{ty as M,Cu as R,LT as a,Fb as b,sv as c,ff as d,z0 as e,iv as f,Hu as g,uv as h,Ey as i,b as j,$1 as k,Uc as n,RT as o,BT as p,le as r,cf as s,de as u,kf as v};
@@ -26,4 +26,4 @@ You are a presentation expert running inside Pneuma Slide Mode. The user views y
26
26
  - Use it to create contextual illustrations, diagrams, and visuals for slides
27
27
  - Always prefer CSS/SVG for geometric shapes and icons — use AI images for photos and complex illustrations
28
28
  - Place generated images in \`assets/\` and reference with \`<img src="assets/...">\`
29
- {{/imageGenEnabled}}`,envMapping:{OPENROUTER_API_KEY:"openrouterApiKey",FAL_KEY:"falApiKey"}},viewer:{watchPatterns:["slides/*.html","manifest.json","theme.css","assets/**/*"],ignorePatterns:["node_modules/**",".git/**",".claude/**",".pneuma/**"],serveDir:"."},agent:{permissionMode:"bypassPermissions",greeting:"The user just opened the Pneuma slide editor. Greet them briefly (1-2 sentences) and let them know you can create full presentation decks from scratch (with design outlines and themed slides) or edit existing slides. Mention they can describe a topic to get started."},init:{contentCheckPattern:"slides/*.html",seedFiles:{"modes/slide/seed/manifest.json":"manifest.json","modes/slide/seed/theme.css":"theme.css","modes/slide/seed/slides/slide-01.html":"slides/slide-01.html","modes/slide/seed/slides/slide-02.html":"slides/slide-02.html"},params:[{name:"slideWidth",label:"Slide width",description:"pixels",type:"number",defaultValue:1280},{name:"slideHeight",label:"Slide height",description:"pixels",type:"number",defaultValue:720},{name:"openrouterApiKey",label:"OpenRouter API Key",description:"for AI image generation, leave blank to skip",type:"string",defaultValue:""},{name:"falApiKey",label:"fal.ai API Key",description:"for AI image generation, leave blank to skip",type:"string",defaultValue:""}],deriveParams:e=>({...e,imageGenEnabled:e.openrouterApiKey||e.falApiKey?"true":""})}};export{s as default};
29
+ {{/imageGenEnabled}}`,envMapping:{OPENROUTER_API_KEY:"openrouterApiKey",FAL_KEY:"falApiKey"}},viewer:{watchPatterns:["slides/*.html","manifest.json","theme.css","assets/**/*"],ignorePatterns:["node_modules/**",".git/**",".claude/**",".pneuma/**"],serveDir:"."},agent:{permissionMode:"bypassPermissions",greeting:"The user just opened the Pneuma slide editor. Greet them briefly (1-2 sentences) and let them know you can create full presentation decks from scratch (with design outlines and themed slides) or edit existing slides. Mention they can describe a topic to get started."},init:{contentCheckPattern:"slides/*.html",seedFiles:{"modes/slide/seed/manifest.json":"manifest.json","modes/slide/seed/theme.css":"theme.css","modes/slide/seed/slides/slide-01.html":"slides/slide-01.html","modes/slide/seed/slides/slide-02.html":"slides/slide-02.html"},params:[{name:"slideWidth",label:"Slide width",description:"pixels",type:"number",defaultValue:1280},{name:"slideHeight",label:"Slide height",description:"pixels",type:"number",defaultValue:720},{name:"openrouterApiKey",label:"OpenRouter API Key",description:"for AI image generation, leave blank to skip",type:"string",defaultValue:"",sensitive:!0},{name:"falApiKey",label:"fal.ai API Key",description:"for AI image generation, leave blank to skip",type:"string",defaultValue:"",sensitive:!0}],deriveParams:e=>({...e,imageGenEnabled:e.openrouterApiKey||e.falApiKey?"true":""})}};export{s as default};