@openchamber/web 1.9.0 → 1.9.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.
@@ -1,16 +1,16 @@
1
- import{w as v,a as ue,j as s,dz as Ye,eO as _e,aO as $e,cr as Te,cq as He,aT as Xe,bj as Je,cn as Me,bt as Qe,bh as Le,O as et,a_ as tt,aS as Ie,ci as nt,Z as st,cj as it,co as rt,aR as ot,cp as at,aa as Oe,b3 as lt,r as ct,E as Fe,aA as dt}from"./vendor-.bun-CFSqfaPx.js";import{c as fe,D as ut,t as je,g as Ve,f as ft,r as mt,a as ht,b as pt,d as gt,S as Ue,e as bt,u as xt,h as Ce,p as wt,i as Pe,j as yt,k as jt}from"./main-WWCGfUVj.js";import"./index-DwBYZzfk.js";const vt=80,Nt=20,kt=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Tt=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${kt(e)}:${String(t)};`).join(""),St=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),_t=n=>{const e=[];return Object.entries(n).forEach(([t,r])=>{const a=St(t);if(a.length===0)return;const l=Tt(r);l&&e.push(`${a.join(",")}{${l}}`)}),e.join(`
1
+ import{w as j,a as ue,j as s,dz as Ye,eQ as _e,aO as $e,cr as Te,cq as He,aT as Qe,bl as Xe,cn as Me,bv as Je,bj as Le,O as et,a_ as tt,aS as Ie,ci as nt,Z as st,cj as it,co as rt,aR as ot,cp as at,aa as Oe,b3 as lt,r as ct,E as Fe,aA as dt}from"./vendor-.bun-CbwevZxt.js";import{c as fe,D as ut,t as ve,g as Ve,f as ft,r as mt,a as ht,b as pt,d as gt,S as Ue,e as bt,u as xt,h as Ce,p as wt,i as Pe,j as yt,k as vt}from"./main-De6o1hBt.js";import"./index-DxSaS6H8.js";const jt=80,Nt=20,kt=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Tt=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${kt(e)}:${String(t)};`).join(""),St=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),_t=n=>{const e=[];return Object.entries(n).forEach(([t,r])=>{const a=St(t);if(a.length===0)return;const l=Tt(r);l&&e.push(`${a.join(",")}{${l}}`)}),e.join(`
2
2
  `)},Rt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},Mt=n=>{const e=n.toLowerCase();return Rt[e]??e},Lt=5e3,be=new Map,It=(n,e)=>{const t=Mt(e),r=`${t}
3
- ${n}`,a=be.get(r);if(a!==void 0)return a;const l=_e.languages[t]??_e.languages.text;if(!l){const i=Ee(n);return be.set(r,i),i}try{const i=_e.highlight(n,l,t);if(be.size>=Lt){const o=be.keys().next().value;typeof o=="string"&&be.delete(o)}return be.set(r,i),i}catch{const i=Ee(n);return be.set(r,i),i}};function Ee(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const We=v.memo(n=>{const e=ue.c(26),{lines:t,language:r,syntaxTheme:a,maxHeight:l,showLineNumbers:i,lineStyles:o}=n,c=l===void 0?"60vh":l,d=i===void 0?!0:i;let m;e[0]!==a?(m=_t(a),e[0]=a,e[1]=m):m=e[1];const T=m;if(!(t.length>vt)){let p;e[2]!==c?(p={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=p):p=e[3];let y;e[4]!==T?(y=T?s.jsx("style",{children:T}):null,e[4]=T,e[5]=y):y=e[5];let w;if(e[6]!==r||e[7]!==o||e[8]!==t||e[9]!==d){let g;e[11]!==r||e[12]!==o||e[13]!==d?(g=(_,N)=>s.jsx(Re,{line:_,language:r,showLineNumbers:d,style:o?.(_)},N),e[11]=r,e[12]=o,e[13]=d,e[14]=g):g=e[14],w=t.map(g),e[6]=r,e[7]=o,e[8]=t,e[9]=d,e[10]=w}else w=e[10];let S;return e[15]!==p||e[16]!==y||e[17]!==w?(S=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:p,children:[y,w]}),e[15]=p,e[16]=y,e[17]=w,e[18]=S):S=e[18],S}let L;return e[19]!==r||e[20]!==o||e[21]!==t||e[22]!==c||e[23]!==T||e[24]!==d?(L=s.jsx(Be,{lines:t,language:r,prismThemeCss:T,maxHeight:c,showLineNumbers:d,lineStyles:o}),e[19]=r,e[20]=o,e[21]=t,e[22]=c,e[23]=T,e[24]=d,e[25]=L):L=e[25],L});We.displayName="VirtualizedCodeBlock";const Be=v.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:r,showLineNumbers:a,lineStyles:l})=>{const i=v.useRef(null),o=Ye({count:n.length,getScrollElement:()=>i.current,estimateSize:()=>Nt,overscan:20});return s.jsxs("div",{ref:i,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:r,overflow:"auto"},children:[t?s.jsx("style",{children:t}):null,s.jsx("div",{style:{height:`${o.getTotalSize()}px`,width:"100%",position:"relative"},children:o.getVirtualItems().map(c=>{const d=n[c.index];return s.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:s.jsx(Re,{line:d,language:e,showLineNumbers:a,style:l?.(d)})},c.index)})})]})});Be.displayName="VirtualizedRows";const Re=v.memo(n=>{const e=ue.c(15),{line:t,language:r,showLineNumbers:a,style:l}=n;let i;e[0]!==r||e[1]!==t.text?(i=It(t.text,r),e[0]=r,e[1]=t.text,e[2]=i):i=e[2];const o=i;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==a?(c=a&&s.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==o||e[8]!==t.isInfo||e[9]!==t.text?(d=s.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?s.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):s.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:o}})}),e[7]=o,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let m;return e[11]!==l||e[12]!==c||e[13]!==d?(m=s.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:l,children:[c,d]}),e[11]=l,e[12]=c,e[13]=d,e[14]=m):m=e[14],m});Re.displayName="VirtualizedCodeBlock.Row";const Ct=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?s.jsx(Xe,{className:e}):t==="image-preview"?s.jsx(Je,{className:e}):t==="mermaid-preview"?s.jsx(Me,{className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?s.jsx(Qe,{className:e}):t==="write"||t==="create"||t==="file_write"?s.jsx(Le,{className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?s.jsx(Le,{className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?s.jsx(et,{className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?s.jsx(tt,{className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?s.jsx(Ie,{className:e}):t==="glob"?s.jsx(nt,{className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?s.jsx(st,{className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?s.jsx(Ie,{className:e}):t==="todowrite"||t==="todoread"?s.jsx(it,{className:e}):t==="plan_enter"?s.jsx(Me,{className:e}):t==="plan_exit"?s.jsx(rt,{className:e}):t.startsWith("git")?s.jsx(ot,{className:e}):s.jsx($e,{className:e})},ze=150,Pt=40,Et=120,zt=3,Dt=`
3
+ ${n}`,a=be.get(r);if(a!==void 0)return a;const l=_e.languages[t]??_e.languages.text;if(!l){const i=Ee(n);return be.set(r,i),i}try{const i=_e.highlight(n,l,t);if(be.size>=Lt){const o=be.keys().next().value;typeof o=="string"&&be.delete(o)}return be.set(r,i),i}catch{const i=Ee(n);return be.set(r,i),i}};function Ee(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const We=j.memo(n=>{const e=ue.c(26),{lines:t,language:r,syntaxTheme:a,maxHeight:l,showLineNumbers:i,lineStyles:o}=n,c=l===void 0?"60vh":l,d=i===void 0?!0:i;let m;e[0]!==a?(m=_t(a),e[0]=a,e[1]=m):m=e[1];const T=m;if(!(t.length>jt)){let p;e[2]!==c?(p={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=p):p=e[3];let y;e[4]!==T?(y=T?s.jsx("style",{children:T}):null,e[4]=T,e[5]=y):y=e[5];let w;if(e[6]!==r||e[7]!==o||e[8]!==t||e[9]!==d){let g;e[11]!==r||e[12]!==o||e[13]!==d?(g=(_,N)=>s.jsx(Re,{line:_,language:r,showLineNumbers:d,style:o?.(_)},N),e[11]=r,e[12]=o,e[13]=d,e[14]=g):g=e[14],w=t.map(g),e[6]=r,e[7]=o,e[8]=t,e[9]=d,e[10]=w}else w=e[10];let S;return e[15]!==p||e[16]!==y||e[17]!==w?(S=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:p,children:[y,w]}),e[15]=p,e[16]=y,e[17]=w,e[18]=S):S=e[18],S}let L;return e[19]!==r||e[20]!==o||e[21]!==t||e[22]!==c||e[23]!==T||e[24]!==d?(L=s.jsx(Be,{lines:t,language:r,prismThemeCss:T,maxHeight:c,showLineNumbers:d,lineStyles:o}),e[19]=r,e[20]=o,e[21]=t,e[22]=c,e[23]=T,e[24]=d,e[25]=L):L=e[25],L});We.displayName="VirtualizedCodeBlock";const Be=j.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:r,showLineNumbers:a,lineStyles:l})=>{const i=j.useRef(null),o=Ye({count:n.length,getScrollElement:()=>i.current,estimateSize:()=>Nt,overscan:20});return s.jsxs("div",{ref:i,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:r,overflow:"auto"},children:[t?s.jsx("style",{children:t}):null,s.jsx("div",{style:{height:`${o.getTotalSize()}px`,width:"100%",position:"relative"},children:o.getVirtualItems().map(c=>{const d=n[c.index];return s.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:s.jsx(Re,{line:d,language:e,showLineNumbers:a,style:l?.(d)})},c.index)})})]})});Be.displayName="VirtualizedRows";const Re=j.memo(n=>{const e=ue.c(15),{line:t,language:r,showLineNumbers:a,style:l}=n;let i;e[0]!==r||e[1]!==t.text?(i=It(t.text,r),e[0]=r,e[1]=t.text,e[2]=i):i=e[2];const o=i;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==a?(c=a&&s.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==o||e[8]!==t.isInfo||e[9]!==t.text?(d=s.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?s.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):s.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:o}})}),e[7]=o,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let m;return e[11]!==l||e[12]!==c||e[13]!==d?(m=s.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:l,children:[c,d]}),e[11]=l,e[12]=c,e[13]=d,e[14]=m):m=e[14],m});Re.displayName="VirtualizedCodeBlock.Row";const Ct=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?s.jsx(Qe,{className:e}):t==="image-preview"?s.jsx(Xe,{className:e}):t==="mermaid-preview"?s.jsx(Me,{className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?s.jsx(Je,{className:e}):t==="write"||t==="create"||t==="file_write"?s.jsx(Le,{className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?s.jsx(Le,{className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?s.jsx(et,{className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?s.jsx(tt,{className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?s.jsx(Ie,{className:e}):t==="glob"?s.jsx(nt,{className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?s.jsx(st,{className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?s.jsx(Ie,{className:e}):t==="todowrite"||t==="todoread"?s.jsx(it,{className:e}):t==="plan_enter"?s.jsx(Me,{className:e}):t==="plan_exit"?s.jsx(rt,{className:e}):t.startsWith("git")?s.jsx(ot,{className:e}):s.jsx($e,{className:e})},ze=150,Pt=40,Et=120,zt=3,Dt=`
4
4
  [data-diff-header],
5
5
  [data-diff] {
6
6
  [data-separator] {
7
7
  height: 24px !important;
8
8
  }
9
9
  }
10
- `,At={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,fileGap:0},$t=()=>{const n=ue.c(22),e=xt();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Ce(!1),n[0]=t):t=n[0];const r=t;let a;n[1]===Symbol.for("react.memo_cache_sentinel")?(a=Ce(!0),n[1]=a):a=n[1];const l=a;let i;n[2]!==e?.availableThemes?(i=()=>e?.availableThemes??[r,l],n[2]=e?.availableThemes,n[3]=i):i=n[3],e?.availableThemes;let o;n[4]!==i?(o=i(),n[4]=i,n[5]=o):o=n[5];const c=o,d=e?.lightThemeId??r.metadata.id,m=e?.darkThemeId??l.metadata.id;let T;n[6]!==c||n[7]!==d?(T=c.find(x=>x.metadata.id===d)??r,n[6]=c,n[7]=d,n[8]=T):T=n[8];const M=T;let L;n[9]!==c||n[10]!==m?(L=c.find(x=>x.metadata.id===m)??l,n[9]=c,n[10]=m,n[11]=L):L=n[11];const p=L;let y,w;n[12]!==p||n[13]!==M?(y=()=>{Pe(M),Pe(p)},w=[p,M],n[12]=p,n[13]=M,n[14]=y,n[15]=w):(y=n[14],w=n[15]),v.useEffect(y,w);const S=e?.currentTheme.metadata.variant??"light";let g;n[16]!==p.metadata.id||n[17]!==M.metadata.id?(g={light:M.metadata.id,dark:p.metadata.id},n[16]=p.metadata.id,n[17]=M.metadata.id,n[18]=g):g=n[18];const _=S==="dark"?"dark":"light";let N;return n[19]!==g||n[20]!==_?(N={theme:g,themeType:_},n[19]=g,n[20]=_,n[21]=N):N=n[21],N},De=()=>({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}),Ae={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Ht=(n,e)=>{const t=e?Ae.mobile:Ae.desktop,r=Math.max(160,n.width-t.padding*2),a=Math.max(160,n.height-t.padding*2);return{maxWidth:Math.max(160,Math.min(r,n.width*t.widthRatio)),maxHeight:Math.max(160,Math.min(a,n.height*t.heightRatio))}},Ot=n=>{try{const l=Array.from(n.querySelectorAll("g"));let i=0,o=null;for(const c of l){if(!(c instanceof SVGGraphicsElement))continue;const d=c.getBBox();if(!(d.width>0&&d.height>0))continue;const m=d.width*d.height;m>i&&(i=m,o=d.width/d.height)}if(o&&Number.isFinite(o)&&o>0)return o}catch{}const e=n.getAttribute("viewBox");if(e){const l=e.trim().split(/\s+/).map(Number);if(l.length===4){const i=l[2],o=l[3];if(Number.isFinite(i)&&Number.isFinite(o)&&i>0&&o>0)return i/o}}const t=Number(n.getAttribute("width")),r=Number(n.getAttribute("height"));if(Number.isFinite(t)&&Number.isFinite(r)&&t>0&&r>0)return t/r;const a=n.getBoundingClientRect();return a.width>0&&a.height>0?a.width/a.height:null},Ge=n=>{const e=ue.c(7),[t,r]=v.useState(n),[a,l]=v.useState(n),[i,o]=v.useState(!1);let c,d;e[0]!==n?(c=()=>{if(n){if(r(!0),o(!0),typeof window>"u"){l(!0);return}const M=window.requestAnimationFrame(()=>{l(!0)}),L=window.setTimeout(()=>{o(!1)},ze);return()=>{window.cancelAnimationFrame(M),window.clearTimeout(L)}}if(l(!1),o(!0),typeof window>"u"){r(!1);return}const T=window.setTimeout(()=>{r(!1),o(!1)},ze);return()=>{window.clearTimeout(T)}},d=[n],e[0]=n,e[1]=c,e[2]=d):(c=e[1],d=e[2]),v.useEffect(c,d);let m;return e[3]!==t||e[4]!==i||e[5]!==a?(m={isRendered:t,isVisible:a,isTransitioning:i},e[3]=t,e[4]=i,e[5]=a,e[6]=m):m=e[6],m},qe=n=>{const e=ue.c(3),[t,r]=v.useState(De);let a,l;return e[0]!==n?(a=()=>{if(!n||typeof window>"u")return;const i=()=>{r(De())};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},l=[n],e[0]=n,e[1]=a,e[2]=l):(a=e[1],l=e[2]),v.useEffect(a,l),t},Ft=n=>{const e=ue.c(99),{popup:t,onOpenChange:r,isMobile:a}=n;let l;e:{const u=t.image;if(!u){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=[],e[0]=R):R=e[0],l=R;break e}let h;e[1]!==u.gallery?(h=Array.isArray(u.gallery)?u.gallery.filter(Ut):[],e[1]=u.gallery,e[2]=h):h=e[2];const P=h;if(P.length>0){l=P;break e}let E;e[3]!==u.filename||e[4]!==u.mimeType||e[5]!==u.size||e[6]!==u.url?(E=[{url:u.url,mimeType:u.mimeType,filename:u.filename,size:u.size}],e[3]=u.filename,e[4]=u.mimeType,e[5]=u.size,e[6]=u.url,e[7]=E):E=e[7],l=E}const i=l,[o,c]=v.useState(0),[d,m]=v.useState(null),{isRendered:T,isVisible:M,isTransitioning:L}=Ge(t.open),p=qe(t.open);let y;e[8]!==i||e[9]!==t.image||e[10]!==t.open?(y=()=>{if(!t.open||i.length===0)return;const u=typeof t.image?.index=="number"?t.image.index:-1;if(u>=0&&u<i.length){c(u);return}const h=t.image?.url?i.findIndex(P=>P.url===t.image?.url):-1;c(h>=0?h:0)},e[8]=i,e[9]=t.image,e[10]=t.open,e[11]=y):y=e[11];const w=t.image?.index,S=t.image?.url;let g;e[12]!==i||e[13]!==t.open||e[14]!==w||e[15]!==S?(g=[i,w,S,t.open],e[12]=i,e[13]=t.open,e[14]=w,e[15]=S,e[16]=g):g=e[16],v.useEffect(y,g);const _=i[o]??i[0]??t.image,N=_?.filename||t.title||"Image preview",x=i.length>1;let b;e[17]!==i.length?(b=()=>{i.length<=1||c(u=>(u-1+i.length)%i.length)},e[17]=i.length,e[18]=b):b=e[18];const k=b;let C;e[19]!==i.length?(C=()=>{i.length<=1||c(u=>(u+1)%i.length)},e[19]=i.length,e[20]=C):C=e[20];const f=C;let G,I;e[21]!==x||e[22]!==r||e[23]!==t.open||e[24]!==f||e[25]!==k?(G=()=>{if(!t.open)return;const u=h=>{if(h.key==="Escape"){r(!1);return}if(h.key==="ArrowLeft"&&x){h.preventDefault(),k();return}h.key==="ArrowRight"&&x&&(h.preventDefault(),f())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},I=[x,r,t.open,f,k],e[21]=x,e[22]=r,e[23]=t.open,e[24]=f,e[25]=k,e[26]=G,e[27]=I):(G=e[26],I=e[27]),v.useEffect(G,I);let Z;e[28]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{m(null)},e[28]=Z):Z=e[28];const q=_?.url;let ee;e[29]!==q?(ee=[q],e[29]=q,e[30]=ee):ee=e[30],v.useEffect(Z,ee);let xe;e:{const u=Math.max(160,p.width*(a?.86:.75)),h=Math.max(160,p.height*(a?.72:.75));if(!d){let we;e[31]!==u?(we=Math.round(u),e[31]=u,e[32]=we):we=e[32];let ye;e[33]!==h?(ye=Math.round(h),e[33]=h,e[34]=ye):ye=e[34];let ke;e[35]!==we||e[36]!==ye?(ke={width:we,height:ye},e[35]=we,e[36]=ye,e[37]=ke):ke=e[37],xe=ke;break e}const P=u/d.width,E=h/d.height,R=Math.min(P,E);let z;e[38]!==d.width||e[39]!==R?(z=Math.round(d.width*R),e[38]=d.width,e[39]=R,e[40]=z):z=e[40];const K=Math.max(1,z);let ve;e[41]!==d.height||e[42]!==R?(ve=Math.round(d.height*R),e[41]=d.height,e[42]=R,e[43]=ve):ve=e[43];const Se=Math.max(1,ve);let Ne;e[44]!==K||e[45]!==Se?(Ne={width:K,height:Se},e[44]=K,e[45]=Se,e[46]=Ne):Ne=e[46],xe=Ne}const me=xe;if(!T||!_||typeof document>"u")return null;const te=t.open?"pointer-events-auto":"pointer-events-none";let ne;e[47]!==te?(ne=fe("fixed inset-0 z-50",te),e[47]=te,e[48]=ne):ne=e[48];const he=L&&"transition-opacity duration-150 ease-out",se=M?"opacity-100":"opacity-0";let A;e[49]!==he||e[50]!==se?(A=fe("absolute inset-0 bg-black/25 backdrop-blur-md",he,se),e[49]=he,e[50]=se,e[51]=A):A=e[51];let $;e[52]!==r?($=()=>r(!1),e[52]=r,e[53]=$):$=e[53];let ie;e[54]!==A||e[55]!==$?(ie=s.jsx("div",{"aria-hidden":"true",className:A,onMouseDown:$}),e[54]=A,e[55]=$,e[56]=ie):ie=e[56];let H;e[57]!==x||e[58]!==f||e[59]!==k?(H=x&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onMouseDown:Wt,onClick:k,className:"absolute left-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Previous image",children:s.jsx(lt,{className:"h-6 w-6"})}),s.jsx("button",{type:"button",onMouseDown:Bt,onClick:f,className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Next image",children:s.jsx(ct,{className:"h-6 w-6"})})]}),e[57]=x,e[58]=f,e[59]=k,e[60]=H):H=e[60];const pe=a?"p-2.5":"p-4";let re;e[61]!==pe?(re=fe("absolute inset-0 flex items-center justify-center pointer-events-none",pe),e[61]=pe,e[62]=re):re=e[62];const oe=L&&"transition-opacity duration-150 ease-out",ge=M?"opacity-100":"opacity-0";let O;e[63]!==oe||e[64]!==ge?(O=fe("pointer-events-auto flex flex-col gap-2",oe,ge),e[63]=oe,e[64]=ge,e[65]=O):O=e[65];const ae=`${me.width}px`;let Y;e[66]!==ae?(Y={width:ae},e[66]=ae,e[67]=Y):Y=e[67];let F;e[68]!==N?(F=s.jsx("div",{className:"min-w-0 flex-1 text-foreground typography-ui-header font-semibold truncate",title:N,children:N}),e[68]=N,e[69]=F):F=e[69];let le;e[70]!==r?(le=()=>r(!1),e[70]=r,e[71]=le):le=e[71];let X;e[72]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(Fe,{className:"h-4 w-4"}),e[72]=X):X=e[72];let V;e[73]!==le?(V=s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:le,"aria-label":"Close image preview",children:X}),e[73]=le,e[74]=V):V=e[74];let U;e[75]!==F||e[76]!==V?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[F,V]}),e[75]=F,e[76]=V,e[77]=U):U=e[77];const ce=`${me.width}px`,de=`${me.height}px`;let W;e[78]!==ce||e[79]!==de?(W={width:ce,height:de},e[78]=ce,e[79]=de,e[80]=W):W=e[80];let J;e[81]===Symbol.for("react.memo_cache_sentinel")?(J=u=>{const h=u.currentTarget,P=h.naturalWidth,E=h.naturalHeight;P>0&&E>0&&m(R=>R&&R.width===P&&R.height===E?R:{width:P,height:E})},e[81]=J):J=e[81];let B;e[82]!==_.url||e[83]!==N||e[84]!==W?(B=s.jsx("img",{src:_.url,alt:N,className:"block object-contain",style:W,loading:"lazy",onLoad:J}),e[82]=_.url,e[83]=N,e[84]=W,e[85]=B):B=e[85];let Q;e[86]!==O||e[87]!==Y||e[88]!==U||e[89]!==B?(Q=s.jsxs("div",{className:O,style:Y,children:[U,B]}),e[86]=O,e[87]=Y,e[88]=U,e[89]=B,e[90]=Q):Q=e[90];let j;e[91]!==re||e[92]!==Q?(j=s.jsx("div",{className:re,children:Q}),e[91]=re,e[92]=Q,e[93]=j):j=e[93];let D;if(e[94]!==ne||e[95]!==ie||e[96]!==H||e[97]!==j){const u=s.jsxs("div",{className:ne,children:[ie,H,j]});D=Oe.createPortal(u,document.body),e[94]=ne,e[95]=ie,e[96]=H,e[97]=j,e[98]=D}else D=e[98];return D},Ke=v.memo(n=>{const e=ue.c(7),{popup:t,diffViewMode:r,pierreThemeConfig:a}=n,l=t.content||"",i=r==="unified"?"unified":"split";let o;e[0]!==a.theme||e[1]!==a.themeType||e[2]!==i?(o={diffStyle:i,diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:"wrap",theme:a.theme,themeType:a.themeType,unsafeCSS:Dt},e[0]=a.theme,e[1]=a.themeType,e[2]=i,e[3]=o):o=e[3];let c;return e[4]!==l||e[5]!==o?(c=s.jsx("div",{className:"typography-code",children:s.jsx(at,{patch:l,metrics:At,options:o,className:"block w-full"})}),e[4]=l,e[5]=o,e[6]=c):c=e[6],c});Ke.displayName="DialogUnifiedDiff";const Ze=v.memo(n=>{const e=ue.c(30),{popup:t,syntaxTheme:r,pierreThemeConfig:a}=n;let l;e[0]!==t.content?(l=wt(t.content),e[0]=t.content,e[1]=l):l=e[1];const i=l,o=t.metadata?.input;let c;e[2]!==o?(c=typeof o=="object"&&o!==null?o:{},e[2]=o,e[3]=c):c=e[3];const d=c,m=typeof d.offset=="number"?d.offset:0,T=typeof d.file_path=="string"?d.file_path:typeof d.filePath=="string"?d.filePath:typeof d.path=="string"?d.path:"read-output";let M;e[4]!==i.lines?(M=i.lines.map(Gt).join(`
11
- `),e[4]=i.lines,e[5]=M):M=e[5];const L=M;let p;e[6]!==T||e[7]!==t.language?(p=t.language||Ve(T)||"text",e[6]=T,e[7]=t.language,e[8]=p):p=e[8];const y=p;let w;e[9]!==i.lines?(w=i.lines.some(qt),e[9]=i.lines,e[10]=w):w=e[10];const S=w;let g;if(e[11]!==S||e[12]!==m||e[13]!==i.lines||e[14]!==i.type){g=[];let x=m;for(const b of i.lines){b.lineNumber!==null&&(x=b.lineNumber);const k=i.type==="file"&&!S&&b.lineNumber===null&&!b.isInfo,C=b.lineNumber??(k?x+1:null);typeof C=="number"&&(x=C),g.push({text:b.text,lineNumber:C,isInfo:b.isInfo})}e[11]=S,e[12]=m,e[13]=i.lines,e[14]=i.type,e[15]=g}else g=e[15];const _=g;if(i.type==="file"){const x=y||void 0;let b;e[16]!==L||e[17]!==T||e[18]!==x?(b={name:T,contents:L,lang:x},e[16]=L,e[17]=T,e[18]=x,e[19]=b):b=e[19];let k;e[20]!==a.theme||e[21]!==a.themeType?(k={disableFileHeader:!0,overflow:"wrap",theme:a.theme,themeType:a.themeType},e[20]=a.theme,e[21]=a.themeType,e[22]=k):k=e[22];let C;return e[23]!==b||e[24]!==k?(C=s.jsx(He,{file:b,options:k,className:"block w-full"}),e[23]=b,e[24]=k,e[25]=C):C=e[25],C}let N;return e[26]!==_||e[27]!==y||e[28]!==r?(N=s.jsx(We,{lines:_,language:y,syntaxTheme:r,maxHeight:"70vh"}),e[26]=_,e[27]=y,e[28]=r,e[29]=N):N=e[29],N});Ze.displayName="DialogReadContent";const Vt=n=>{const e=ue.c(83),{popup:t,onOpenChange:r,isMobile:a}=n,[l,i]=v.useState(t.mermaid?.source||""),[o,c]=v.useState(t.mermaid?.source?"ready":"idle"),[d,m]=v.useState(""),{isRendered:T,isVisible:M,isTransitioning:L}=Ge(t.open),[p,y]=v.useState(null),w=qe(t.open),S=v.useRef(0),g=v.useRef(null),_=Xt,N=Jt;let x;e[0]!==t.mermaid?(x=async()=>{const j=t.mermaid;if(!j?.url){c("error"),m("Missing Mermaid source URL.");return}if(j.source){i(j.source),c("ready"),m("");return}const D=S.current+1;S.current=D,c("loading"),m("");let u;if(j.url.startsWith("data:"))u=Promise.resolve(N(j.url));else if(j.url.toLowerCase().startsWith("file://")){const h=_(j.url);h?u=fetch(`/api/fs/raw?path=${encodeURIComponent(h)}`).then(Qt):u=Promise.reject(new Error("Invalid local file path for Mermaid preview."))}else{const P=(typeof URL.canParse=="function"?URL.canParse(j.url,window.location.origin):!1)?new URL(j.url,window.location.origin):null;!P||P.protocol!=="http:"&&P.protocol!=="https:"?u=Promise.reject(new Error("Unsupported Mermaid URL protocol.")):u=fetch(P.toString()).then(en)}await u.then(h=>{S.current===D&&(i(h),c("ready"))}).catch(h=>{S.current===D&&(c("error"),m(h instanceof Error?h.message:"Unable to load Mermaid diagram."))})},e[0]=t.mermaid,e[1]=x):x=e[1];const b=x;let k,C;e[2]!==b||e[3]!==t.mermaid||e[4]!==t.open?(k=()=>{!t.open||!t.mermaid||b()},C=[b,t.mermaid,t.open],e[2]=b,e[3]=t.mermaid,e[4]=t.open,e[5]=k,e[6]=C):(k=e[5],C=e[6]),v.useEffect(k,C);let f,G;e[7]!==r||e[8]!==t.open?(f=()=>{if(!t.open)return;const j=D=>{D.key==="Escape"&&r(!1)};return window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}},G=[r,t.open],e[7]=r,e[8]=t.open,e[9]=f,e[10]=G):(f=e[9],G=e[10]),v.useEffect(f,G);let I;e[11]!==t.open||e[12]!==o?(I=()=>{if(!t.open||o!=="ready"){y(null);return}const j=()=>{const R=g.current?.querySelector("svg");if(!R)return!1;const z=Ot(R);return!z||!Number.isFinite(z)||z<=0?!1:(y(K=>K&&Math.abs(K-z)<.001?K:z),!0)};let D=window.requestAnimationFrame(()=>{j()||(D=window.requestAnimationFrame(()=>{j()}))}),u=0,h;const P=()=>{u>=zt||(h=window.setTimeout(()=>{u=u+1,j()||P()},Et))};P();const E=new MutationObserver(()=>{j()});return g.current&&E.observe(g.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(D),typeof h=="number"&&window.clearTimeout(h),E.disconnect()}},e[11]=t.open,e[12]=o,e[13]=I):I=e[13];let Z;e[14]!==t.open||e[15]!==l||e[16]!==o?(Z=[t.open,l,o],e[14]=t.open,e[15]=l,e[16]=o,e[17]=Z):Z=e[17],v.useEffect(I,Z);const q=`\`\`\`mermaid
10
+ `,At={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,fileGap:0},$t=()=>{const n=ue.c(22),e=xt();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Ce(!1),n[0]=t):t=n[0];const r=t;let a;n[1]===Symbol.for("react.memo_cache_sentinel")?(a=Ce(!0),n[1]=a):a=n[1];const l=a;let i;n[2]!==e?.availableThemes?(i=()=>e?.availableThemes??[r,l],n[2]=e?.availableThemes,n[3]=i):i=n[3],e?.availableThemes;let o;n[4]!==i?(o=i(),n[4]=i,n[5]=o):o=n[5];const c=o,d=e?.lightThemeId??r.metadata.id,m=e?.darkThemeId??l.metadata.id;let T;n[6]!==c||n[7]!==d?(T=c.find(x=>x.metadata.id===d)??r,n[6]=c,n[7]=d,n[8]=T):T=n[8];const M=T;let L;n[9]!==c||n[10]!==m?(L=c.find(x=>x.metadata.id===m)??l,n[9]=c,n[10]=m,n[11]=L):L=n[11];const p=L;let y,w;n[12]!==p||n[13]!==M?(y=()=>{Pe(M),Pe(p)},w=[p,M],n[12]=p,n[13]=M,n[14]=y,n[15]=w):(y=n[14],w=n[15]),j.useEffect(y,w);const S=e?.currentTheme.metadata.variant??"light";let g;n[16]!==p.metadata.id||n[17]!==M.metadata.id?(g={light:M.metadata.id,dark:p.metadata.id},n[16]=p.metadata.id,n[17]=M.metadata.id,n[18]=g):g=n[18];const _=S==="dark"?"dark":"light";let N;return n[19]!==g||n[20]!==_?(N={theme:g,themeType:_},n[19]=g,n[20]=_,n[21]=N):N=n[21],N},De=()=>({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}),Ae={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},Ht=(n,e)=>{const t=e?Ae.mobile:Ae.desktop,r=Math.max(160,n.width-t.padding*2),a=Math.max(160,n.height-t.padding*2);return{maxWidth:Math.max(160,Math.min(r,n.width*t.widthRatio)),maxHeight:Math.max(160,Math.min(a,n.height*t.heightRatio))}},Ot=n=>{try{const l=Array.from(n.querySelectorAll("g"));let i=0,o=null;for(const c of l){if(!(c instanceof SVGGraphicsElement))continue;const d=c.getBBox();if(!(d.width>0&&d.height>0))continue;const m=d.width*d.height;m>i&&(i=m,o=d.width/d.height)}if(o&&Number.isFinite(o)&&o>0)return o}catch{}const e=n.getAttribute("viewBox");if(e){const l=e.trim().split(/\s+/).map(Number);if(l.length===4){const i=l[2],o=l[3];if(Number.isFinite(i)&&Number.isFinite(o)&&i>0&&o>0)return i/o}}const t=Number(n.getAttribute("width")),r=Number(n.getAttribute("height"));if(Number.isFinite(t)&&Number.isFinite(r)&&t>0&&r>0)return t/r;const a=n.getBoundingClientRect();return a.width>0&&a.height>0?a.width/a.height:null},Ge=n=>{const e=ue.c(7),[t,r]=j.useState(n),[a,l]=j.useState(n),[i,o]=j.useState(!1);let c,d;e[0]!==n?(c=()=>{if(n){if(r(!0),o(!0),typeof window>"u"){l(!0);return}const M=window.requestAnimationFrame(()=>{l(!0)}),L=window.setTimeout(()=>{o(!1)},ze);return()=>{window.cancelAnimationFrame(M),window.clearTimeout(L)}}if(l(!1),o(!0),typeof window>"u"){r(!1);return}const T=window.setTimeout(()=>{r(!1),o(!1)},ze);return()=>{window.clearTimeout(T)}},d=[n],e[0]=n,e[1]=c,e[2]=d):(c=e[1],d=e[2]),j.useEffect(c,d);let m;return e[3]!==t||e[4]!==i||e[5]!==a?(m={isRendered:t,isVisible:a,isTransitioning:i},e[3]=t,e[4]=i,e[5]=a,e[6]=m):m=e[6],m},qe=n=>{const e=ue.c(3),[t,r]=j.useState(De);let a,l;return e[0]!==n?(a=()=>{if(!n||typeof window>"u")return;const i=()=>{r(De())};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},l=[n],e[0]=n,e[1]=a,e[2]=l):(a=e[1],l=e[2]),j.useEffect(a,l),t},Ft=n=>{const e=ue.c(99),{popup:t,onOpenChange:r,isMobile:a}=n;let l;e:{const u=t.image;if(!u){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=[],e[0]=R):R=e[0],l=R;break e}let h;e[1]!==u.gallery?(h=Array.isArray(u.gallery)?u.gallery.filter(Ut):[],e[1]=u.gallery,e[2]=h):h=e[2];const P=h;if(P.length>0){l=P;break e}let E;e[3]!==u.filename||e[4]!==u.mimeType||e[5]!==u.size||e[6]!==u.url?(E=[{url:u.url,mimeType:u.mimeType,filename:u.filename,size:u.size}],e[3]=u.filename,e[4]=u.mimeType,e[5]=u.size,e[6]=u.url,e[7]=E):E=e[7],l=E}const i=l,[o,c]=j.useState(0),[d,m]=j.useState(null),{isRendered:T,isVisible:M,isTransitioning:L}=Ge(t.open),p=qe(t.open);let y;e[8]!==i||e[9]!==t.image||e[10]!==t.open?(y=()=>{if(!t.open||i.length===0)return;const u=typeof t.image?.index=="number"?t.image.index:-1;if(u>=0&&u<i.length){c(u);return}const h=t.image?.url?i.findIndex(P=>P.url===t.image?.url):-1;c(h>=0?h:0)},e[8]=i,e[9]=t.image,e[10]=t.open,e[11]=y):y=e[11];const w=t.image?.index,S=t.image?.url;let g;e[12]!==i||e[13]!==t.open||e[14]!==w||e[15]!==S?(g=[i,w,S,t.open],e[12]=i,e[13]=t.open,e[14]=w,e[15]=S,e[16]=g):g=e[16],j.useEffect(y,g);const _=i[o]??i[0]??t.image,N=_?.filename||t.title||"Image preview",x=i.length>1;let b;e[17]!==i.length?(b=()=>{i.length<=1||c(u=>(u-1+i.length)%i.length)},e[17]=i.length,e[18]=b):b=e[18];const k=b;let C;e[19]!==i.length?(C=()=>{i.length<=1||c(u=>(u+1)%i.length)},e[19]=i.length,e[20]=C):C=e[20];const f=C;let G,I;e[21]!==x||e[22]!==r||e[23]!==t.open||e[24]!==f||e[25]!==k?(G=()=>{if(!t.open)return;const u=h=>{if(h.key==="Escape"){r(!1);return}if(h.key==="ArrowLeft"&&x){h.preventDefault(),k();return}h.key==="ArrowRight"&&x&&(h.preventDefault(),f())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},I=[x,r,t.open,f,k],e[21]=x,e[22]=r,e[23]=t.open,e[24]=f,e[25]=k,e[26]=G,e[27]=I):(G=e[26],I=e[27]),j.useEffect(G,I);let Z;e[28]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{m(null)},e[28]=Z):Z=e[28];const q=_?.url;let ee;e[29]!==q?(ee=[q],e[29]=q,e[30]=ee):ee=e[30],j.useEffect(Z,ee);let xe;e:{const u=Math.max(160,p.width*(a?.86:.75)),h=Math.max(160,p.height*(a?.72:.75));if(!d){let we;e[31]!==u?(we=Math.round(u),e[31]=u,e[32]=we):we=e[32];let ye;e[33]!==h?(ye=Math.round(h),e[33]=h,e[34]=ye):ye=e[34];let ke;e[35]!==we||e[36]!==ye?(ke={width:we,height:ye},e[35]=we,e[36]=ye,e[37]=ke):ke=e[37],xe=ke;break e}const P=u/d.width,E=h/d.height,R=Math.min(P,E);let z;e[38]!==d.width||e[39]!==R?(z=Math.round(d.width*R),e[38]=d.width,e[39]=R,e[40]=z):z=e[40];const K=Math.max(1,z);let je;e[41]!==d.height||e[42]!==R?(je=Math.round(d.height*R),e[41]=d.height,e[42]=R,e[43]=je):je=e[43];const Se=Math.max(1,je);let Ne;e[44]!==K||e[45]!==Se?(Ne={width:K,height:Se},e[44]=K,e[45]=Se,e[46]=Ne):Ne=e[46],xe=Ne}const me=xe;if(!T||!_||typeof document>"u")return null;const te=t.open?"pointer-events-auto":"pointer-events-none";let ne;e[47]!==te?(ne=fe("fixed inset-0 z-50",te),e[47]=te,e[48]=ne):ne=e[48];const he=L&&"transition-opacity duration-150 ease-out",se=M?"opacity-100":"opacity-0";let A;e[49]!==he||e[50]!==se?(A=fe("absolute inset-0 bg-black/25 backdrop-blur-md",he,se),e[49]=he,e[50]=se,e[51]=A):A=e[51];let $;e[52]!==r?($=()=>r(!1),e[52]=r,e[53]=$):$=e[53];let ie;e[54]!==A||e[55]!==$?(ie=s.jsx("div",{"aria-hidden":"true",className:A,onMouseDown:$}),e[54]=A,e[55]=$,e[56]=ie):ie=e[56];let H;e[57]!==x||e[58]!==f||e[59]!==k?(H=x&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onMouseDown:Wt,onClick:k,className:"absolute left-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Previous image",children:s.jsx(lt,{className:"h-6 w-6"})}),s.jsx("button",{type:"button",onMouseDown:Bt,onClick:f,className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Next image",children:s.jsx(ct,{className:"h-6 w-6"})})]}),e[57]=x,e[58]=f,e[59]=k,e[60]=H):H=e[60];const pe=a?"p-2.5":"p-4";let re;e[61]!==pe?(re=fe("absolute inset-0 flex items-center justify-center pointer-events-none",pe),e[61]=pe,e[62]=re):re=e[62];const oe=L&&"transition-opacity duration-150 ease-out",ge=M?"opacity-100":"opacity-0";let O;e[63]!==oe||e[64]!==ge?(O=fe("pointer-events-auto flex flex-col gap-2",oe,ge),e[63]=oe,e[64]=ge,e[65]=O):O=e[65];const ae=`${me.width}px`;let Y;e[66]!==ae?(Y={width:ae},e[66]=ae,e[67]=Y):Y=e[67];let F;e[68]!==N?(F=s.jsx("div",{className:"min-w-0 flex-1 text-foreground typography-ui-header font-semibold truncate",title:N,children:N}),e[68]=N,e[69]=F):F=e[69];let le;e[70]!==r?(le=()=>r(!1),e[70]=r,e[71]=le):le=e[71];let Q;e[72]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(Fe,{className:"h-4 w-4"}),e[72]=Q):Q=e[72];let V;e[73]!==le?(V=s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:le,"aria-label":"Close image preview",children:Q}),e[73]=le,e[74]=V):V=e[74];let U;e[75]!==F||e[76]!==V?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[F,V]}),e[75]=F,e[76]=V,e[77]=U):U=e[77];const ce=`${me.width}px`,de=`${me.height}px`;let W;e[78]!==ce||e[79]!==de?(W={width:ce,height:de},e[78]=ce,e[79]=de,e[80]=W):W=e[80];let X;e[81]===Symbol.for("react.memo_cache_sentinel")?(X=u=>{const h=u.currentTarget,P=h.naturalWidth,E=h.naturalHeight;P>0&&E>0&&m(R=>R&&R.width===P&&R.height===E?R:{width:P,height:E})},e[81]=X):X=e[81];let B;e[82]!==_.url||e[83]!==N||e[84]!==W?(B=s.jsx("img",{src:_.url,alt:N,className:"block object-contain",style:W,loading:"lazy",onLoad:X}),e[82]=_.url,e[83]=N,e[84]=W,e[85]=B):B=e[85];let J;e[86]!==O||e[87]!==Y||e[88]!==U||e[89]!==B?(J=s.jsxs("div",{className:O,style:Y,children:[U,B]}),e[86]=O,e[87]=Y,e[88]=U,e[89]=B,e[90]=J):J=e[90];let v;e[91]!==re||e[92]!==J?(v=s.jsx("div",{className:re,children:J}),e[91]=re,e[92]=J,e[93]=v):v=e[93];let D;if(e[94]!==ne||e[95]!==ie||e[96]!==H||e[97]!==v){const u=s.jsxs("div",{className:ne,children:[ie,H,v]});D=Oe.createPortal(u,document.body),e[94]=ne,e[95]=ie,e[96]=H,e[97]=v,e[98]=D}else D=e[98];return D},Ke=j.memo(n=>{const e=ue.c(7),{popup:t,diffViewMode:r,pierreThemeConfig:a}=n,l=t.content||"",i=r==="unified"?"unified":"split";let o;e[0]!==a.theme||e[1]!==a.themeType||e[2]!==i?(o={diffStyle:i,diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:"wrap",theme:a.theme,themeType:a.themeType,unsafeCSS:Dt},e[0]=a.theme,e[1]=a.themeType,e[2]=i,e[3]=o):o=e[3];let c;return e[4]!==l||e[5]!==o?(c=s.jsx("div",{className:"typography-code",children:s.jsx(at,{patch:l,metrics:At,options:o,className:"block w-full"})}),e[4]=l,e[5]=o,e[6]=c):c=e[6],c});Ke.displayName="DialogUnifiedDiff";const Ze=j.memo(n=>{const e=ue.c(30),{popup:t,syntaxTheme:r,pierreThemeConfig:a}=n;let l;e[0]!==t.content?(l=wt(t.content),e[0]=t.content,e[1]=l):l=e[1];const i=l,o=t.metadata?.input;let c;e[2]!==o?(c=typeof o=="object"&&o!==null?o:{},e[2]=o,e[3]=c):c=e[3];const d=c,m=typeof d.offset=="number"?d.offset:0,T=typeof d.file_path=="string"?d.file_path:typeof d.filePath=="string"?d.filePath:typeof d.path=="string"?d.path:"read-output";let M;e[4]!==i.lines?(M=i.lines.map(Gt).join(`
11
+ `),e[4]=i.lines,e[5]=M):M=e[5];const L=M;let p;e[6]!==T||e[7]!==t.language?(p=t.language||Ve(T)||"text",e[6]=T,e[7]=t.language,e[8]=p):p=e[8];const y=p;let w;e[9]!==i.lines?(w=i.lines.some(qt),e[9]=i.lines,e[10]=w):w=e[10];const S=w;let g;if(e[11]!==S||e[12]!==m||e[13]!==i.lines||e[14]!==i.type){g=[];let x=m;for(const b of i.lines){b.lineNumber!==null&&(x=b.lineNumber);const k=i.type==="file"&&!S&&b.lineNumber===null&&!b.isInfo,C=b.lineNumber??(k?x+1:null);typeof C=="number"&&(x=C),g.push({text:b.text,lineNumber:C,isInfo:b.isInfo})}e[11]=S,e[12]=m,e[13]=i.lines,e[14]=i.type,e[15]=g}else g=e[15];const _=g;if(i.type==="file"){const x=y||void 0;let b;e[16]!==L||e[17]!==T||e[18]!==x?(b={name:T,contents:L,lang:x},e[16]=L,e[17]=T,e[18]=x,e[19]=b):b=e[19];let k;e[20]!==a.theme||e[21]!==a.themeType?(k={disableFileHeader:!0,overflow:"wrap",theme:a.theme,themeType:a.themeType},e[20]=a.theme,e[21]=a.themeType,e[22]=k):k=e[22];let C;return e[23]!==b||e[24]!==k?(C=s.jsx(He,{file:b,options:k,className:"block w-full"}),e[23]=b,e[24]=k,e[25]=C):C=e[25],C}let N;return e[26]!==_||e[27]!==y||e[28]!==r?(N=s.jsx(We,{lines:_,language:y,syntaxTheme:r,maxHeight:"70vh"}),e[26]=_,e[27]=y,e[28]=r,e[29]=N):N=e[29],N});Ze.displayName="DialogReadContent";const Vt=n=>{const e=ue.c(83),{popup:t,onOpenChange:r,isMobile:a}=n,[l,i]=j.useState(t.mermaid?.source||""),[o,c]=j.useState(t.mermaid?.source?"ready":"idle"),[d,m]=j.useState(""),{isRendered:T,isVisible:M,isTransitioning:L}=Ge(t.open),[p,y]=j.useState(null),w=qe(t.open),S=j.useRef(0),g=j.useRef(null),_=Qt,N=Xt;let x;e[0]!==t.mermaid?(x=async()=>{const v=t.mermaid;if(!v?.url){c("error"),m("Missing Mermaid source URL.");return}if(v.source){i(v.source),c("ready"),m("");return}const D=S.current+1;S.current=D,c("loading"),m("");let u;if(v.url.startsWith("data:"))u=Promise.resolve(N(v.url));else if(v.url.toLowerCase().startsWith("file://")){const h=_(v.url);h?u=fetch(`/api/fs/raw?path=${encodeURIComponent(h)}`).then(Jt):u=Promise.reject(new Error("Invalid local file path for Mermaid preview."))}else{const P=(typeof URL.canParse=="function"?URL.canParse(v.url,window.location.origin):!1)?new URL(v.url,window.location.origin):null;!P||P.protocol!=="http:"&&P.protocol!=="https:"?u=Promise.reject(new Error("Unsupported Mermaid URL protocol.")):u=fetch(P.toString()).then(en)}await u.then(h=>{S.current===D&&(i(h),c("ready"))}).catch(h=>{S.current===D&&(c("error"),m(h instanceof Error?h.message:"Unable to load Mermaid diagram."))})},e[0]=t.mermaid,e[1]=x):x=e[1];const b=x;let k,C;e[2]!==b||e[3]!==t.mermaid||e[4]!==t.open?(k=()=>{!t.open||!t.mermaid||b()},C=[b,t.mermaid,t.open],e[2]=b,e[3]=t.mermaid,e[4]=t.open,e[5]=k,e[6]=C):(k=e[5],C=e[6]),j.useEffect(k,C);let f,G;e[7]!==r||e[8]!==t.open?(f=()=>{if(!t.open)return;const v=D=>{D.key==="Escape"&&r(!1)};return window.addEventListener("keydown",v),()=>{window.removeEventListener("keydown",v)}},G=[r,t.open],e[7]=r,e[8]=t.open,e[9]=f,e[10]=G):(f=e[9],G=e[10]),j.useEffect(f,G);let I;e[11]!==t.open||e[12]!==o?(I=()=>{if(!t.open||o!=="ready"){y(null);return}const v=()=>{const R=g.current?.querySelector("svg");if(!R)return!1;const z=Ot(R);return!z||!Number.isFinite(z)||z<=0?!1:(y(K=>K&&Math.abs(K-z)<.001?K:z),!0)};let D=window.requestAnimationFrame(()=>{v()||(D=window.requestAnimationFrame(()=>{v()}))}),u=0,h;const P=()=>{u>=zt||(h=window.setTimeout(()=>{u=u+1,v()||P()},Et))};P();const E=new MutationObserver(()=>{v()});return g.current&&E.observe(g.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(D),typeof h=="number"&&window.clearTimeout(h),E.disconnect()}},e[11]=t.open,e[12]=o,e[13]=I):I=e[13];let Z;e[14]!==t.open||e[15]!==l||e[16]!==o?(Z=[t.open,l,o],e[14]=t.open,e[15]=l,e[16]=o,e[17]=Z):Z=e[17],j.useEffect(I,Z);const q=`\`\`\`mermaid
12
12
  ${l}
13
- \`\`\``;let ee;if(e[18]!==p||e[19]!==a||e[20]!==w){e:{const{maxWidth:j,maxHeight:D}=Ht(w,a),u=Math.max(160,D-Pt);if(p&&p<1){const E=Math.min(j,u);let R;e[22]!==E?(R=Math.round(E),e[22]=E,e[23]=R):R=e[23];let z;e[24]!==E?(z=Math.round(E),e[24]=E,e[25]=z):z=e[25];let K;e[26]!==z||e[27]!==R?(K={width:R,height:z},e[26]=z,e[27]=R,e[28]=K):K=e[28],ee=K;break e}const h=Math.round(j);let P;e[29]!==u?(P=Math.round(u),e[29]=u,e[30]=P):P=e[30],ee={width:h,height:P}}e[18]=p,e[19]=a,e[20]=w,e[21]=ee}else ee=e[21];const xe=ee;if(!T||typeof document>"u")return null;const me=t.open?"pointer-events-auto":"pointer-events-none";let te;e[31]!==me?(te=fe("fixed inset-0 z-50",me),e[31]=me,e[32]=te):te=e[32];const ne=L&&"transition-opacity duration-150 ease-out",he=M?"opacity-100":"opacity-0";let se;e[33]!==ne||e[34]!==he?(se=fe("absolute inset-0 bg-black/25 backdrop-blur-md",ne,he),e[33]=ne,e[34]=he,e[35]=se):se=e[35];let A;e[36]!==r?(A=()=>r(!1),e[36]=r,e[37]=A):A=e[37];let $;e[38]!==se||e[39]!==A?($=s.jsx("div",{"aria-hidden":"true",className:se,onMouseDown:A}),e[38]=se,e[39]=A,e[40]=$):$=e[40];const ie=a?"p-2.5":"p-4";let H;e[41]!==ie?(H=fe("absolute inset-0 flex items-center justify-center pointer-events-none",ie),e[41]=ie,e[42]=H):H=e[42];const pe=L&&"transition-opacity duration-150 ease-out",re=M?"opacity-100":"opacity-0";let oe;e[43]!==pe||e[44]!==re?(oe=fe("pointer-events-auto flex flex-col gap-2",pe,re),e[43]=pe,e[44]=re,e[45]=oe):oe=e[45];const ge=`${xe.width}px`;let O;e[46]!==ge?(O={width:ge},e[46]=ge,e[47]=O):O=e[47];let ae;e[48]!==r?(ae=()=>r(!1),e[48]=r,e[49]=ae):ae=e[49];let Y;e[50]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Fe,{className:"h-4 w-4"}),e[50]=Y):Y=e[50];let F;e[51]!==ae?(F=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:ae,"aria-label":"Close diagram preview",children:Y})}),e[51]=ae,e[52]=F):F=e[52];const le=`${xe.height}px`;let X;e[53]!==le?(X={height:le},e[53]=le,e[54]=X):X=e[54];let V;e[55]!==o?(V=o==="loading"&&s.jsxs("div",{className:"h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta",children:[s.jsx(dt,{className:"h-4 w-4 animate-spin"}),s.jsx("span",{children:"Loading diagram..."})]}),e[55]=o,e[56]=V):V=e[56];let U;e[57]!==d||e[58]!==b||e[59]!==o?(U=o==="error"&&s.jsxs("div",{className:"rounded-xl border border-border/30 bg-muted/20 p-3 space-y-3",children:[s.jsx("p",{className:"typography-markdown",style:{color:"var(--status-error)"},children:d||"Unable to render Mermaid diagram."}),s.jsx("button",{type:"button",onClick:()=>{b()},className:"px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]",style:{borderColor:"var(--interactive-border)",color:"var(--surface-foreground)"},children:"Retry"})]}),e[57]=d,e[58]=b,e[59]=o,e[60]=U):U=e[60];let ce;e[61]!==q||e[62]!==o?(ce=o==="ready"&&s.jsx("div",{ref:g,className:"h-full",children:s.jsx(Ue,{content:q,variant:"tool",allowMermaidWheelZoom:!0,className:"streamdown-mermaid-fullscreen h-full [&_[data-streamdown='mermaid-block']_button]:hidden",mermaidControls:{download:!1,copy:!1,fullscreen:!1,panZoom:!0}})}),e[61]=q,e[62]=o,e[63]=ce):ce=e[63];let de;e[64]!==V||e[65]!==U||e[66]!==ce?(de=s.jsxs("div",{className:"h-full overflow-hidden",children:[V,U,ce]}),e[64]=V,e[65]=U,e[66]=ce,e[67]=de):de=e[67];let W;e[68]!==X||e[69]!==de?(W=s.jsx("div",{className:"relative overflow-hidden",style:X,children:de}),e[68]=X,e[69]=de,e[70]=W):W=e[70];let J;e[71]!==oe||e[72]!==O||e[73]!==F||e[74]!==W?(J=s.jsxs("div",{className:oe,style:O,onMouseDown:tn,children:[F,W]}),e[71]=oe,e[72]=O,e[73]=F,e[74]=W,e[75]=J):J=e[75];let B;e[76]!==H||e[77]!==J?(B=s.jsx("div",{className:H,children:J}),e[76]=H,e[77]=J,e[78]=B):B=e[78];let Q;if(e[79]!==te||e[80]!==$||e[81]!==B){const j=s.jsxs("div",{className:te,children:[$,B]});Q=Oe.createPortal(j,document.body),e[79]=te,e[80]=$,e[81]=B,e[82]=Q}else Q=e[82];return Q},on=n=>{const e=ue.c(49),{popup:t,onOpenChange:r,syntaxTheme:a,isMobile:l}=n,[i,o]=v.useState("unified"),c=$t();let d;e[0]!==t.open?(d=()=>{t.open&&o("unified")},e[0]=t.open,e[1]=d):d=e[1];let m;if(e[2]!==t.open||e[3]!==t.title?(m=[t.open,t.title],e[2]=t.open,e[3]=t.title,e[4]=m):m=e[4],v.useEffect(d,m),t.image){let f;return e[5]!==l||e[6]!==r||e[7]!==t?(f=s.jsx(Ft,{popup:t,onOpenChange:r,isMobile:l}),e[5]=l,e[6]=r,e[7]=t,e[8]=f):f=e[8],f}if(t.mermaid){let f;return e[9]!==l||e[10]!==r||e[11]!==t?(f=s.jsx(Vt,{popup:t,onOpenChange:r,isMobile:l}),e[9]=l,e[10]=r,e[11]=t,e[12]=f):f=e[12],f}const T=t.open,M=l?"w-[95vw] max-w-[95vw]":"max-w-5xl",L=l?"[&>button]:right-1":"[&>button]:top-2.5 [&>button]:right-4";let p;e[13]!==M||e[14]!==L?(p=fe("overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1","[&>button]:top-1.5",M,L),e[13]=M,e[14]=L,e[15]=p):p=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y={maxHeight:"90vh"},e[16]=y):y=e[16];let w;e[17]!==t.metadata?(w=t.metadata?.tool?Ct(t.metadata.tool):s.jsx($e,{className:"h-3.5 w-3.5 text-foreground flex-shrink-0"}),e[17]=t.metadata,e[18]=w):w=e[18];let S;e[19]!==t.title?(S=s.jsx("span",{className:"break-words flex-1 leading-tight",children:t.title}),e[19]=t.title,e[20]=S):S=e[20];let g;e[21]!==i||e[22]!==t.isDiff?(g=t.isDiff&&s.jsx(ut,{mode:i,onModeChange:o,className:"mr-8 flex-shrink-0"}),e[21]=i,e[22]=t.isDiff,e[23]=g):g=e[23];let _;e[24]!==g||e[25]!==w||e[26]!==S?(_=s.jsx("div",{className:"flex-shrink-0 pb-1",children:s.jsxs("div",{className:"flex items-start gap-2 text-foreground typography-ui-header font-semibold",children:[w,S,g]})}),e[24]=g,e[25]=w,e[26]=S,e[27]=_):_=e[27];let N;e[28]!==c||e[29]!==t.metadata||e[30]!==a?(N=t.metadata?.input&&typeof t.metadata.input=="object"&&Object.keys(t.metadata.input).length>0&&t.metadata?.tool!=="todowrite"&&t.metadata?.tool!=="todoread"&&t.metadata?.tool!=="apply_patch"?(()=>{const f=t.metadata,G=f.input,I=Z=>{const q=G[Z];return typeof q=="string"?q:typeof q=="number"?String(q):null};return s.jsxs("div",{className:"border-b border-border/20 p-4 -mx-3",children:[s.jsx("div",{className:"typography-markdown font-medium text-muted-foreground mb-2 px-3",children:f.tool==="bash"?"Command:":f.tool==="task"?"Task Details:":"Input:"}),f.tool==="bash"&&I("command")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(Te,{style:a,language:"bash",PreTag:"div",customStyle:je.getPopupStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},wrapLongLines:!0,children:I("command")})}):f.tool==="task"&&I("prompt")?s.jsxs("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:je.getPopupStyles(),children:[I("description")?`Task: ${I("description")}
13
+ \`\`\``;let ee;if(e[18]!==p||e[19]!==a||e[20]!==w){e:{const{maxWidth:v,maxHeight:D}=Ht(w,a),u=Math.max(160,D-Pt);if(p&&p<1){const E=Math.min(v,u);let R;e[22]!==E?(R=Math.round(E),e[22]=E,e[23]=R):R=e[23];let z;e[24]!==E?(z=Math.round(E),e[24]=E,e[25]=z):z=e[25];let K;e[26]!==z||e[27]!==R?(K={width:R,height:z},e[26]=z,e[27]=R,e[28]=K):K=e[28],ee=K;break e}const h=Math.round(v);let P;e[29]!==u?(P=Math.round(u),e[29]=u,e[30]=P):P=e[30],ee={width:h,height:P}}e[18]=p,e[19]=a,e[20]=w,e[21]=ee}else ee=e[21];const xe=ee;if(!T||typeof document>"u")return null;const me=t.open?"pointer-events-auto":"pointer-events-none";let te;e[31]!==me?(te=fe("fixed inset-0 z-50",me),e[31]=me,e[32]=te):te=e[32];const ne=L&&"transition-opacity duration-150 ease-out",he=M?"opacity-100":"opacity-0";let se;e[33]!==ne||e[34]!==he?(se=fe("absolute inset-0 bg-black/25 backdrop-blur-md",ne,he),e[33]=ne,e[34]=he,e[35]=se):se=e[35];let A;e[36]!==r?(A=()=>r(!1),e[36]=r,e[37]=A):A=e[37];let $;e[38]!==se||e[39]!==A?($=s.jsx("div",{"aria-hidden":"true",className:se,onMouseDown:A}),e[38]=se,e[39]=A,e[40]=$):$=e[40];const ie=a?"p-2.5":"p-4";let H;e[41]!==ie?(H=fe("absolute inset-0 flex items-center justify-center pointer-events-none",ie),e[41]=ie,e[42]=H):H=e[42];const pe=L&&"transition-opacity duration-150 ease-out",re=M?"opacity-100":"opacity-0";let oe;e[43]!==pe||e[44]!==re?(oe=fe("pointer-events-auto flex flex-col gap-2",pe,re),e[43]=pe,e[44]=re,e[45]=oe):oe=e[45];const ge=`${xe.width}px`;let O;e[46]!==ge?(O={width:ge},e[46]=ge,e[47]=O):O=e[47];let ae;e[48]!==r?(ae=()=>r(!1),e[48]=r,e[49]=ae):ae=e[49];let Y;e[50]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Fe,{className:"h-4 w-4"}),e[50]=Y):Y=e[50];let F;e[51]!==ae?(F=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:ae,"aria-label":"Close diagram preview",children:Y})}),e[51]=ae,e[52]=F):F=e[52];const le=`${xe.height}px`;let Q;e[53]!==le?(Q={height:le},e[53]=le,e[54]=Q):Q=e[54];let V;e[55]!==o?(V=o==="loading"&&s.jsxs("div",{className:"h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta",children:[s.jsx(dt,{className:"h-4 w-4 animate-spin"}),s.jsx("span",{children:"Loading diagram..."})]}),e[55]=o,e[56]=V):V=e[56];let U;e[57]!==d||e[58]!==b||e[59]!==o?(U=o==="error"&&s.jsxs("div",{className:"rounded-xl border border-border/30 bg-muted/20 p-3 space-y-3",children:[s.jsx("p",{className:"typography-markdown",style:{color:"var(--status-error)"},children:d||"Unable to render Mermaid diagram."}),s.jsx("button",{type:"button",onClick:()=>{b()},className:"px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]",style:{borderColor:"var(--interactive-border)",color:"var(--surface-foreground)"},children:"Retry"})]}),e[57]=d,e[58]=b,e[59]=o,e[60]=U):U=e[60];let ce;e[61]!==q||e[62]!==o?(ce=o==="ready"&&s.jsx("div",{ref:g,className:"h-full",children:s.jsx(Ue,{content:q,variant:"tool",allowMermaidWheelZoom:!0,className:"streamdown-mermaid-fullscreen h-full [&_[data-streamdown='mermaid-block']_button]:hidden",mermaidControls:{download:!1,copy:!1,fullscreen:!1,panZoom:!0}})}),e[61]=q,e[62]=o,e[63]=ce):ce=e[63];let de;e[64]!==V||e[65]!==U||e[66]!==ce?(de=s.jsxs("div",{className:"h-full overflow-hidden",children:[V,U,ce]}),e[64]=V,e[65]=U,e[66]=ce,e[67]=de):de=e[67];let W;e[68]!==Q||e[69]!==de?(W=s.jsx("div",{className:"relative overflow-hidden",style:Q,children:de}),e[68]=Q,e[69]=de,e[70]=W):W=e[70];let X;e[71]!==oe||e[72]!==O||e[73]!==F||e[74]!==W?(X=s.jsxs("div",{className:oe,style:O,onMouseDown:tn,children:[F,W]}),e[71]=oe,e[72]=O,e[73]=F,e[74]=W,e[75]=X):X=e[75];let B;e[76]!==H||e[77]!==X?(B=s.jsx("div",{className:H,children:X}),e[76]=H,e[77]=X,e[78]=B):B=e[78];let J;if(e[79]!==te||e[80]!==$||e[81]!==B){const v=s.jsxs("div",{className:te,children:[$,B]});J=Oe.createPortal(v,document.body),e[79]=te,e[80]=$,e[81]=B,e[82]=J}else J=e[82];return J},on=n=>{const e=ue.c(49),{popup:t,onOpenChange:r,syntaxTheme:a,isMobile:l}=n,[i,o]=j.useState("unified"),c=$t();let d;e[0]!==t.open?(d=()=>{t.open&&o("unified")},e[0]=t.open,e[1]=d):d=e[1];let m;if(e[2]!==t.open||e[3]!==t.title?(m=[t.open,t.title],e[2]=t.open,e[3]=t.title,e[4]=m):m=e[4],j.useEffect(d,m),t.image){let f;return e[5]!==l||e[6]!==r||e[7]!==t?(f=s.jsx(Ft,{popup:t,onOpenChange:r,isMobile:l}),e[5]=l,e[6]=r,e[7]=t,e[8]=f):f=e[8],f}if(t.mermaid){let f;return e[9]!==l||e[10]!==r||e[11]!==t?(f=s.jsx(Vt,{popup:t,onOpenChange:r,isMobile:l}),e[9]=l,e[10]=r,e[11]=t,e[12]=f):f=e[12],f}const T=t.open,M=l?"w-[95vw] max-w-[95vw]":"max-w-5xl",L=l?"[&>button]:right-1":"[&>button]:top-2.5 [&>button]:right-4";let p;e[13]!==M||e[14]!==L?(p=fe("overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1","[&>button]:top-1.5",M,L),e[13]=M,e[14]=L,e[15]=p):p=e[15];let y;e[16]===Symbol.for("react.memo_cache_sentinel")?(y={maxHeight:"90vh"},e[16]=y):y=e[16];let w;e[17]!==t.metadata?(w=t.metadata?.tool?Ct(t.metadata.tool):s.jsx($e,{className:"h-3.5 w-3.5 text-foreground flex-shrink-0"}),e[17]=t.metadata,e[18]=w):w=e[18];let S;e[19]!==t.title?(S=s.jsx("span",{className:"break-words flex-1 leading-tight",children:t.title}),e[19]=t.title,e[20]=S):S=e[20];let g;e[21]!==i||e[22]!==t.isDiff?(g=t.isDiff&&s.jsx(ut,{mode:i,onModeChange:o,className:"mr-8 flex-shrink-0"}),e[21]=i,e[22]=t.isDiff,e[23]=g):g=e[23];let _;e[24]!==g||e[25]!==w||e[26]!==S?(_=s.jsx("div",{className:"flex-shrink-0 pb-1",children:s.jsxs("div",{className:"flex items-start gap-2 text-foreground typography-ui-header font-semibold",children:[w,S,g]})}),e[24]=g,e[25]=w,e[26]=S,e[27]=_):_=e[27];let N;e[28]!==c||e[29]!==t.metadata||e[30]!==a?(N=t.metadata?.input&&typeof t.metadata.input=="object"&&Object.keys(t.metadata.input).length>0&&t.metadata?.tool!=="todowrite"&&t.metadata?.tool!=="todoread"&&t.metadata?.tool!=="apply_patch"?(()=>{const f=t.metadata,G=f.input,I=Z=>{const q=G[Z];return typeof q=="string"?q:typeof q=="number"?String(q):null};return s.jsxs("div",{className:"border-b border-border/20 p-4 -mx-3",children:[s.jsx("div",{className:"typography-markdown font-medium text-muted-foreground mb-2 px-3",children:f.tool==="bash"?"Command:":f.tool==="task"?"Task Details:":"Input:"}),f.tool==="bash"&&I("command")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(Te,{style:a,language:"bash",PreTag:"div",customStyle:ve.getPopupStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},wrapLongLines:!0,children:I("command")})}):f.tool==="task"&&I("prompt")?s.jsxs("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:ve.getPopupStyles(),children:[I("description")?`Task: ${I("description")}
14
14
  `:"",I("subagent_type")?`Agent Type: ${I("subagent_type")}
15
15
  `:"",`Instructions:
16
- ${I("prompt")}`]}):f.tool==="write"&&I("content")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(He,{file:{name:I("filePath")||I("file_path")||"new-file",contents:I("content"),lang:Ve(I("filePath")||I("file_path")||"")||void 0},options:{disableFileHeader:!0,overflow:"wrap",theme:c.theme,themeType:c.themeType},className:"block w-full"})}):s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:je.getPopupStyles(),children:ft(G,f.tool)})]})})():null,e[28]=c,e[29]=t.metadata,e[30]=a,e[31]=N):N=e[31];let x;e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==t||e[36]!==a?(x=t.isDiff?s.jsx(Ke,{popup:t,diffViewMode:i,pierreThemeConfig:c}):t.content?s.jsx("div",{className:"p-4",children:(()=>{const f=t.metadata?.tool;return f==="todowrite"||f==="todoread"?mt(t.content)||s.jsx(Te,{style:a,language:"json",PreTag:"div",wrapLongLines:!0,customStyle:je.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="list"?ht(t.content)||s.jsx("pre",{className:"typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="grep"?pt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="glob"?gt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="task"||f==="reasoning"?s.jsx("div",{className:f==="reasoning"?"text-muted-foreground/70":"",children:s.jsx(Ue,{content:t.content,variant:"tool"})}):f==="web-search"||f==="websearch"||f==="search_web"?bt(t.content)||s.jsx(Te,{style:a,language:"text",PreTag:"div",wrapLongLines:!0,customStyle:je.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="read"?s.jsx(Ze,{popup:t,syntaxTheme:a,pierreThemeConfig:c}):s.jsx(Te,{style:a,language:t.language||"text",PreTag:"div",wrapLongLines:!0,customStyle:je.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content})})()}):s.jsxs("div",{className:"p-8 text-muted-foreground typography-ui-header",children:[s.jsx("div",{className:"mb-2",children:"Command completed successfully"}),s.jsx("div",{className:"typography-meta",children:"No output was produced"})]}),e[32]=i,e[33]=l,e[34]=c,e[35]=t,e[36]=a,e[37]=x):x=e[37];let b;e[38]!==N||e[39]!==x?(b=s.jsx("div",{className:"flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden",children:s.jsxs("div",{className:"tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4",children:[N,x]})}),e[38]=N,e[39]=x,e[40]=b):b=e[40];let k;e[41]!==_||e[42]!==b||e[43]!==p?(k=s.jsxs(yt,{className:p,style:y,children:[_,b]}),e[41]=_,e[42]=b,e[43]=p,e[44]=k):k=e[44];let C;return e[45]!==r||e[46]!==t.open||e[47]!==k?(C=s.jsx(jt,{open:T,onOpenChange:r,children:k}),e[45]=r,e[46]=t.open,e[47]=k,e[48]=C):C=e[48],C};function Ut(n){return!!n?.url}function Wt(n){return n.stopPropagation()}function Bt(n){return n.stopPropagation()}function Gt(n){return n.text}function qt(n){return n.lineNumber!==null}function Kt(n){if(!n||/[\0\r\n]/.test(n))return!1;const e=n.replace(/\\/g,"/");return e.split("/").filter(Boolean).includes("..")?!1:e.startsWith("/")?!0:/^[A-Za-z]:\//.test(e)}function Zt(n,e){const t=Number.parseInt(e,16);return Number.isFinite(t)?String.fromCharCode(t):`%${e}`}function Yt(n){return n.replace(/%([0-9A-Fa-f]{2})/g,Zt)}function Xt(n){const e=n.trim();if(!e.toLowerCase().startsWith("file://"))return null;const t=Kt,r=Yt;if(typeof URL.canParse=="function"?URL.canParse(e):!1){let o=r(new URL(e).pathname||"");return/^\/[A-Za-z]:\//.test(o)&&(o=o.slice(1)),t(o)?o:null}const l=e.replace(/^file:\/\//i,""),i=r(l);return t(i)?i:t(l)?l:null}function Jt(n){const e=n.indexOf(",");if(e<0)throw new Error("Malformed data URL");const t=n.slice(0,e).toLowerCase(),r=n.slice(e+1);return t.includes(";base64")?atob(r):decodeURIComponent(r)}function Qt(n){return n.ok?n.text():Promise.reject(new Error(`Failed to read diagram file (${n.status})`))}function en(n){return n.ok?n.text():Promise.reject(new Error(`Failed to load diagram (${n.status})`))}function tn(n){return n.stopPropagation()}export{on as default};
16
+ ${I("prompt")}`]}):f.tool==="write"&&I("content")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(He,{file:{name:I("filePath")||I("file_path")||"new-file",contents:I("content"),lang:Ve(I("filePath")||I("file_path")||"")||void 0},options:{disableFileHeader:!0,overflow:"wrap",theme:c.theme,themeType:c.themeType},className:"block w-full"})}):s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:ve.getPopupStyles(),children:ft(G,f.tool)})]})})():null,e[28]=c,e[29]=t.metadata,e[30]=a,e[31]=N):N=e[31];let x;e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==t||e[36]!==a?(x=t.isDiff?s.jsx(Ke,{popup:t,diffViewMode:i,pierreThemeConfig:c}):t.content?s.jsx("div",{className:"p-4",children:(()=>{const f=t.metadata?.tool;return f==="todowrite"||f==="todoread"?mt(t.content)||s.jsx(Te,{style:a,language:"json",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="list"?ht(t.content)||s.jsx("pre",{className:"typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="grep"?pt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="glob"?gt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="task"||f==="reasoning"?s.jsx("div",{className:f==="reasoning"?"text-muted-foreground/70":"",children:s.jsx(Ue,{content:t.content,variant:"tool"})}):f==="web-search"||f==="websearch"||f==="search_web"?bt(t.content)||s.jsx(Te,{style:a,language:"text",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="read"?s.jsx(Ze,{popup:t,syntaxTheme:a,pierreThemeConfig:c}):s.jsx(Te,{style:a,language:t.language||"text",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content})})()}):s.jsxs("div",{className:"p-8 text-muted-foreground typography-ui-header",children:[s.jsx("div",{className:"mb-2",children:"Command completed successfully"}),s.jsx("div",{className:"typography-meta",children:"No output was produced"})]}),e[32]=i,e[33]=l,e[34]=c,e[35]=t,e[36]=a,e[37]=x):x=e[37];let b;e[38]!==N||e[39]!==x?(b=s.jsx("div",{className:"flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden",children:s.jsxs("div",{className:"tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4",children:[N,x]})}),e[38]=N,e[39]=x,e[40]=b):b=e[40];let k;e[41]!==_||e[42]!==b||e[43]!==p?(k=s.jsxs(yt,{className:p,style:y,children:[_,b]}),e[41]=_,e[42]=b,e[43]=p,e[44]=k):k=e[44];let C;return e[45]!==r||e[46]!==t.open||e[47]!==k?(C=s.jsx(vt,{open:T,onOpenChange:r,children:k}),e[45]=r,e[46]=t.open,e[47]=k,e[48]=C):C=e[48],C};function Ut(n){return!!n?.url}function Wt(n){return n.stopPropagation()}function Bt(n){return n.stopPropagation()}function Gt(n){return n.text}function qt(n){return n.lineNumber!==null}function Kt(n){if(!n||/[\0\r\n]/.test(n))return!1;const e=n.replace(/\\/g,"/");return e.split("/").filter(Boolean).includes("..")?!1:e.startsWith("/")?!0:/^[A-Za-z]:\//.test(e)}function Zt(n,e){const t=Number.parseInt(e,16);return Number.isFinite(t)?String.fromCharCode(t):`%${e}`}function Yt(n){return n.replace(/%([0-9A-Fa-f]{2})/g,Zt)}function Qt(n){const e=n.trim();if(!e.toLowerCase().startsWith("file://"))return null;const t=Kt,r=Yt;if(typeof URL.canParse=="function"?URL.canParse(e):!1){let o=r(new URL(e).pathname||"");return/^\/[A-Za-z]:\//.test(o)&&(o=o.slice(1)),t(o)?o:null}const l=e.replace(/^file:\/\//i,""),i=r(l);return t(i)?i:t(l)?l:null}function Xt(n){const e=n.indexOf(",");if(e<0)throw new Error("Malformed data URL");const t=n.slice(0,e).toLowerCase(),r=n.slice(e+1);return t.includes(";base64")?atob(r):decodeURIComponent(r)}function Jt(n){return n.ok?n.text():Promise.reject(new Error(`Failed to read diagram file (${n.status})`))}function en(n){return n.ok?n.text():Promise.reject(new Error(`Failed to load diagram (${n.status})`))}function tn(n){return n.stopPropagation()}export{on as default};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-CFSqfaPx.js","assets/vendor--DbVqbJpV.css","assets/main-WWCGfUVj.js","assets/main-BV3KOtdA.css"])))=>i.map(i=>d[i]);
2
- import{_ as J}from"./vendor-.bun-CFSqfaPx.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const s of n)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function r(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(n){if(n.ep)return;n.ep=!0;const s=r(n);fetch(n.href,s)}})();const U=1,S=1,H="/api/terminal/input-ws",Y=1200,V=1e3,X=3e4,Q=250,Z=2e4,tt=5e3,N="__openchamberTerminalInputWsState",et=new TextEncoder,rt=new TextDecoder,M=e=>{if(/^wss?:\/\//i.test(e))return e;if(/^https?:\/\//i.test(e)){const o=new URL(e);return o.protocol=o.protocol==="https:"?"wss:":"ws:",o.toString()}if(typeof window>"u")return"";const t=e.startsWith("/")?e:`/${e}`;return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${t}`},v=e=>{const t=et.encode(JSON.stringify(e)),r=new Uint8Array(t.length+1);return r[0]=U,r.set(t,1),r},B=e=>e?((e.transports??[]).includes("ws")||e.preferred==="ws")&&typeof e.ws?.path=="string"&&e.ws.path.length>0:!1;class q{socket=null;socketUrl="";boundSessionId=null;openPromise=null;reconnectTimeout=null;reconnectAttempt=0;keepaliveInterval=null;closed=!1;configure(t){if(t){if(this.socketUrl===t){if(this.closed=!1,this.isConnectedOrConnecting())return;this.ensureConnected();return}this.socketUrl=t,this.closed=!1,this.resetConnection(),this.ensureConnected()}}async sendInput(t,r){if(!t||!r||this.closed||!this.socketUrl)return!1;const o=await this.getOpenSocket(Y);if(!o||o.readyState!==S)return!1;try{return this.boundSessionId!==t&&(o.send(v({t:"b",s:t,v:1})),this.boundSessionId=t),o.send(r),!0}catch{return this.handleSocketFailure(),!1}}unbindSession(t){t&&this.boundSessionId===t&&(this.boundSessionId=null)}close(){this.closed=!0,this.clearReconnectTimeout(),this.resetConnection(),this.socketUrl=""}prime(){this.closed||!this.socketUrl||this.isConnectedOrConnecting()||this.ensureConnected()}isConnectedOrConnecting(t){return this.closed||t&&this.socketUrl!==t?!1:this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)?!0:this.openPromise!==null}sendControl(t){if(!this.socket||this.socket.readyState!==S)return!1;try{return this.socket.send(v(t)),!0}catch{return this.handleSocketFailure(),!1}}startKeepalive(){this.stopKeepalive(),this.keepaliveInterval=setInterval(()=>{this.closed||this.sendControl({t:"p",v:1})},Z)}stopKeepalive(){this.keepaliveInterval&&(clearInterval(this.keepaliveInterval),this.keepaliveInterval=null)}scheduleReconnect(){if(this.closed||!this.socketUrl||this.reconnectTimeout)return;const t=Math.min(V*Math.pow(2,this.reconnectAttempt),X),r=Math.floor(Math.random()*Q),o=t+r;this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.reconnectAttempt+=1,this.ensureConnected()},o)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}async getOpenSocket(t){if(this.socket&&this.socket.readyState===S)return this.socket;if(this.ensureConnected(),this.socket&&this.socket.readyState===S)return this.socket;const r=await Promise.race([this.openPromise??Promise.resolve(null),new Promise(o=>{setTimeout(()=>o(null),t)})]);return r&&r.readyState===S?r:this.socket&&this.socket.readyState===S?this.socket:null}ensureConnected(){this.closed||!this.socketUrl||this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)||this.openPromise||(this.clearReconnectTimeout(),this.openPromise=new Promise(t=>{let r=!1,o=null;const n=s=>{r||(r=!0,o&&(clearTimeout(o),o=null),this.openPromise=null,t(s))};try{const s=new WebSocket(this.socketUrl);s.binaryType="arraybuffer",s.onopen=()=>{this.socket=s,this.reconnectAttempt=0,this.startKeepalive(),n(s)},s.onmessage=l=>{this.handleSocketMessage(l.data)},s.onclose=()=>{this.socket===s&&(this.socket=null,this.boundSessionId=null,this.stopKeepalive(),this.closed||this.scheduleReconnect()),n(null)},this.socket=s,o=setTimeout(()=>{s.readyState===WebSocket.CONNECTING&&(s.close(),n(null))},tt)}catch{n(null),this.closed||this.scheduleReconnect()}}))}async handleSocketMessage(t){const r=await this.asUint8Array(t);if(!(!r||r.length<2)&&r[0]===U)try{const o=JSON.parse(rt.decode(r.subarray(1)));if(o.t==="po")return;o.t==="e"&&((o.c==="NOT_BOUND"||o.c==="SESSION_NOT_FOUND")&&(this.boundSessionId=null),o.f===!0&&this.handleSocketFailure())}catch{this.handleSocketFailure()}}async asUint8Array(t){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return t;if(typeof Blob<"u"&&t instanceof Blob){const r=await t.arrayBuffer();return new Uint8Array(r)}return null}handleSocketFailure(){this.boundSessionId=null,this.resetConnection(),this.scheduleReconnect()}resetConnection(){if(this.openPromise=null,this.stopKeepalive(),this.socket){const t=this.socket;this.socket=null,t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close()}this.boundSessionId=null}}const g=()=>{const e=globalThis;return e[N]||(e[N]={capability:null,manager:null}),e[N]},z=e=>{const t=g();if(t.capability=e??null,!B(t.capability)){t.manager?.close(),t.manager=null;return}const r=t.capability?.ws?.path;if(!r)return;const o=M(r);o&&(t.manager||(t.manager=new q),t.manager.configure(o))},ot=async(e,t)=>{const r=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain"},body:t});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to send input"}));throw new Error(o.error||"Failed to send terminal input")}};async function nt(e){const t=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e.cwd,cols:e.cols||80,rows:e.rows||24})});if(!t.ok){const o=await t.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(o.error||"Failed to create terminal session")}const r=await t.json();return z(r.capabilities?.input),r}function st(e,t,r,o={}){const{maxRetries:n=3,initialRetryDelay:s=1e3,maxRetryDelay:l=8e3,connectionTimeout:d=1e4}=o;let c=null,h=0,w=null,u=null,y=!1,T=!1,b=!1;const C=()=>{w&&(clearTimeout(w),w=null),u&&(clearTimeout(u),u=null)},P=()=>{y=!0,C(),c&&(c.close(),c=null)},F=()=>{if(!(y||b)){if(c&&c.readyState!==EventSource.CLOSED){console.warn("Attempted to create duplicate EventSource, skipping");return}T=!1,c=new EventSource(`/api/terminal/${e}/stream`),u=setTimeout(()=>{!T&&c?.readyState!==EventSource.OPEN&&(console.error("Terminal connection timeout"),c?.close(),x(new Error("Connection timeout"),!1))},d),c.onopen=()=>{T||(T=!0,h=0,C(),t({type:"connected"}))},c.onmessage=E=>{try{const m=JSON.parse(E.data);m.type==="exit"&&(g().manager?.unbindSession(e),b=!0,P()),t(m)}catch(m){console.error("Failed to parse terminal event:",m),r?.(m,!1)}},c.onerror=E=>{console.error("Terminal stream error:",E,"readyState:",c?.readyState),C();const m=b||c?.readyState===EventSource.CLOSED;c?.close(),c=null,b||x(new Error("Terminal stream connection error"),m)}}},x=(E,m)=>{if(!(y||b))if(h<n&&!m){h++;const I=Math.min(s*Math.pow(2,h-1),l);console.log(`Reconnecting to terminal stream (attempt ${h}/${n}) in ${I}ms`),t({type:"reconnecting",attempt:h,maxAttempts:n}),w=setTimeout(()=>{!y&&!b&&F()},I)}else console.error(`Terminal connection failed after ${h} attempts`),r?.(E,!0),P()};return F(),P}async function it(e,t){const r=g();r.manager&&await r.manager.sendInput(e,t)||await ot(e,t)}async function at(e,t,r){const o=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:t,rows:r})});if(!o.ok){const n=await o.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(n.error||"Failed to resize terminal")}}async function ct(e){g().manager?.unbindSession(e);const t=await fetch(`/api/terminal/${e}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(r.error||"Failed to close terminal")}}async function lt(e,t){g().manager?.unbindSession(e);const r=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(n.error||"Failed to restart terminal")}const o=await r.json();return z(o.capabilities?.input),o}async function ut(e){const t=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}e.sessionId&&g().manager?.unbindSession(e.sessionId)}function we(){const e=g();if(e.capability&&!B(e.capability))return;const t=e.capability?.ws?.path??H,r=M(t);r&&(e.manager||(e.manager=new q),!e.manager.isConnectedOrConnecting(r)&&(e.manager.configure(r),e.manager.prime()))}const dt=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},ht=()=>({async createSession(e){return nt(e)},connect(e,t,r){const o=st(e,t.onEvent,t.onError,dt(r));return{close:()=>o()}},async sendInput(e,t){await it(e,t)},async resize(e){await at(e.sessionId,e.cols,e.rows)},async close(e){await ct(e)},async restartSession(e,t){return lt(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows})},async forceKill(e){await ut(e)}}),ft=()=>{if(typeof window>"u")return"";const e=window.__OPENCHAMBER_DESKTOP_SERVER__?.origin;return e||window.location.origin},i="/api/git",pt=1200,wt=5e3,A=new Map,k=new Map,$=new Map,j=new Map,K=e=>e.trim();function a(e,t,r){const o=new URL(e,ft());if(t&&o.searchParams.set("directory",t),r)for(const[n,s]of Object.entries(r))s!==void 0&&o.searchParams.set(n,String(s));return o.toString()}async function yt(e){const t=K(e),r=Date.now(),o=$.get(t);if(o&&o.expiresAt>r)return o.value;const n=j.get(t);if(n)return n;const s=(async()=>{const l=await fetch(a(`${i}/check`,e));if(!l.ok)throw new Error(`Failed to check git repository: ${l.statusText}`);const c=!!(await l.json()).isGitRepository;return $.set(t,{value:c,expiresAt:Date.now()+wt}),c})();j.set(t,s);try{return await s}finally{j.get(t)===s&&j.delete(t)}}async function mt(e){const t=K(e),r=Date.now(),o=A.get(t);if(o&&o.expiresAt>r)return o.value;const n=k.get(t);if(n)return n;const s=(async()=>{const l=await fetch(a(`${i}/status`,e));if(!l.ok)throw new Error(`Failed to get git status: ${l.statusText}`);const d=await l.json();return A.set(t,{value:d,expiresAt:Date.now()+pt}),d})();k.set(t,s);try{return await s}finally{k.get(t)===s&&k.delete(t)}}async function gt(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const s=await fetch(a(`${i}/diff`,e,{path:r,staged:o?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function Tt(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await fetch(a(`${i}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function bt(e,t){if(!t)throw new Error("path is required to revert git changes");const r=await fetch(a(`${i}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert git changes")}}async function St(e){if(!e)return!1;const t=await fetch(a(`${i}/worktree-type`,e));if(!t.ok)throw new Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function Et(e){const t=await fetch(a(`${i}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function kt(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await fetch(a(`${i}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function jt(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await fetch(a(`${i}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function Ot(e,t){const r=t?.remote?.trim();if(!r)throw new Error("remote is required to remove a remote");const o=await fetch(a(`${i}/remotes`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to remove remote")}return o.json()}async function Ct(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error("No files provided to generate commit message");const o={files:t};r?.zenModel&&(o.zenModel=r.zenModel),r?.providerId&&(o.providerId=r.providerId),r?.modelId&&(o.modelId=r.modelId);const n=await fetch(a(`${i}/commit-message`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!n.ok){const c=await n.json().catch(()=>({error:n.statusText}));console.error("[git-generation][browser] http error",{status:n.status,statusText:n.statusText,error:c});const h=typeof c?.traceId=="string"&&c.traceId?` (traceId: ${c.traceId})`:"";throw new Error(`${c.error||"Failed to generate commit message"}${h}`)}const s=await n.json();if(!s?.message||typeof s.message!="object")throw new Error("Malformed commit generation response");const l=typeof s.message.subject=="string"&&s.message.subject.trim().length>0?s.message.subject.trim():"",d=Array.isArray(s.message.highlights)?s.message.highlights.filter(c=>typeof c=="string"&&c.trim().length>0).map(c=>c.trim()):[];return{message:{subject:l,highlights:d}}}async function Pt(e,t){const{base:r,head:o,context:n,zenModel:s,providerId:l,modelId:d}=t;if(!r||!o)throw new Error("base and head are required");const c={base:r,head:o};n?.trim()&&(c.context=n.trim()),s&&(c.zenModel=s),l&&(c.providerId=l),d&&(c.modelId=d);const h=await fetch(a(`${i}/pr-description`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!h.ok){const T=await h.json().catch(()=>({error:h.statusText}));throw new Error(T.error||"Failed to generate PR description")}const w=await h.json().catch(()=>null),u=typeof w?.title=="string"?w.title:"",y=typeof w?.body=="string"?w.body:"";if(!u&&!y)throw new Error("Malformed PR description response");return{title:u,body:y}}async function R(e){const t=await fetch(a(`${i}/worktrees`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list worktrees")}return t.json()}async function _(e,t){const r=await fetch(a(`${i}/worktrees/validate`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to validate worktree")}return r.json()}async function G(e,t){const r=await fetch(a(`${i}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to create worktree")}return r.json()}async function D(e,t){const r=await fetch(a(`${i}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete worktree")}return r.json()}async function Nt(e,t,r={}){const o=await fetch(a(`${i}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create commit")}return o.json()}async function Ft(e,t={}){const r=await fetch(a(`${i}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to push")}return r.json()}async function xt(e,t={}){const r=await fetch(a(`${i}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to pull")}return r.json()}async function It(e,t={}){const r=await fetch(a(`${i}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to fetch")}return r.json()}async function vt(e,t){const r=await fetch(a(`${i}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout branch")}return r.json()}async function At(e,t,r){const o=await fetch(a(`${i}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function $t(e,t,r){const o=await fetch(a(`${i}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function Rt(e,t={}){const r=await fetch(a(`${i}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file}));if(!r.ok)throw new Error(`Failed to get git log: ${r.statusText}`);return r.json()}async function _t(e,t){const r=await fetch(a(`${i}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function Gt(){const e=await fetch(a(`${i}/identities`,void 0));if(!e.ok)throw new Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Dt(e){const t=await fetch(a(`${i}/identities`,void 0),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to create git identity")}return t.json()}async function Wt(e,t){const r=await fetch(a(`${i}/identities/${e}`,void 0),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to update git identity")}return r.json()}async function Lt(e){const t=await fetch(a(`${i}/identities/${e}`,void 0),{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to delete git identity")}}async function Jt(e){if(!e)return null;const t=await fetch(a(`${i}/current-identity`,e));if(!t.ok)throw new Error(`Failed to get current git identity: ${t.statusText}`);const r=await t.json();return r?{userName:r.userName??null,userEmail:r.userEmail??null,sshCommand:r.sshCommand??null}:null}async function Ut(e){if(!e)return!1;const t=await fetch(a(`${i}/has-local-identity`,e));if(!t.ok)throw new Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function ye(){const e=await fetch(a(`${i}/global-identity`,void 0));if(!e.ok)throw new Error(`Failed to get global git identity: ${e.statusText}`);const t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function Mt(e,t){const r=await fetch(a(`${i}/set-identity`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to set git identity")}return r.json()}async function me(){const e=await fetch(a(`${i}/discover-credentials`,void 0));if(!e.ok)throw new Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function Bt(e){const t=await fetch(a(`${i}/remotes`,e));if(!t.ok)throw new Error(`Failed to get remotes: ${t.statusText}`);return t.json()}async function qt(e,t){const r=await fetch(a(`${i}/rebase`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to rebase")}return r.json()}async function zt(e){const t=await fetch(a(`${i}/rebase/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort rebase")}return t.json()}async function Kt(e,t){const r=await fetch(a(`${i}/merge`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to merge")}return r.json()}async function Ht(e){const t=await fetch(a(`${i}/merge/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort merge")}return t.json()}async function Yt(e){const t=await fetch(a(`${i}/rebase/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue rebase")}return t.json()}async function Vt(e){const t=await fetch(a(`${i}/merge/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue merge")}return t.json()}async function Xt(e,t){const r=await fetch(a(`${i}/stash`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t||{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to stash")}return r.json()}async function Qt(e){const t=await fetch(a(`${i}/stash/pop`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to pop stash")}return t.json()}async function Zt(e){const t=await fetch(a(`${i}/conflict-details`,e));if(!t.ok)throw new Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}const te=()=>({checkIsGitRepository:yt,getGitStatus:mt,getGitDiff:gt,getGitFileDiff:Tt,revertGitFile:bt,isLinkedWorktree:St,getGitBranches:Et,deleteGitBranch:kt,deleteRemoteBranch:jt,removeRemote:Ot,generateCommitMessage:Ct,generatePullRequestDescription:Pt,listGitWorktrees:R,validateGitWorktree:_,createGitWorktree:G,deleteGitWorktree:D,createGitCommit(e,t,r){return Nt(e,t,r)},gitPush:Ft,gitPull:xt,gitFetch:It,checkoutBranch:vt,createBranch:At,renameBranch:$t,getGitLog(e,t){return Rt(e,t)},getCommitFiles:_t,getCurrentGitIdentity:Jt,hasLocalIdentity:Ut,setGitIdentity:Mt,getGitIdentities:Gt,createGitIdentity:Dt,updateGitIdentity:Wt,deleteGitIdentity:Lt,getRemotes:Bt,rebase:qt,abortRebase:zt,continueRebase:Yt,merge:Kt,abortMerge:Ht,continueMerge:Vt,stash:Xt,stashPop:Qt,getConflictDetails:Zt,worktree:{list:R,validate:_,create:G,remove:D}}),p=e=>e.replace(/\\/g,"/"),ee=(e,t)=>{const r=p(t?.directory||t?.path||e),o=Array.isArray(t?.entries)?t.entries:[];return{directory:r,entries:o.filter(n=>!!(n&&typeof n.name=="string"&&typeof n.path=="string")).map(n=>({name:n.name,path:p(n.path),isDirectory:!!n.isDirectory}))}},re=()=>({async listDirectory(e){const t=p(e),r=new URLSearchParams;t&&r.set("path",t);const o=await fetch(`/api/fs/list${r.toString()?`?${r.toString()}`:""}`);if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to list directory")}const n=await o.json();return ee(t,n)},async search(e){const t=new URLSearchParams,r=p(e.directory);r&&t.set("directory",r),t.set("query",e.query),t.set("dirs","false"),t.set("type","file"),typeof e.maxResults=="number"&&Number.isFinite(e.maxResults)&&t.set("limit",String(e.maxResults));const o=await fetch(`/api/find/file?${t.toString()}`);if(!o.ok){const l=await o.json().catch(()=>({error:o.statusText}));throw new Error(l.error||"Failed to search files")}const n=await o.json();return(Array.isArray(n)?n:[]).map(l=>({path:p(`${r}/${l}`),preview:[p(l)]}))},async createDirectory(e){const t=p(e),r=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to create directory")}const o=await r.json();return{success:!!o?.success,path:typeof o?.path=="string"?p(o.path):t}},async readFile(e){const t=p(e),r=await fetch(`/api/fs/read?path=${encodeURIComponent(t)}`);if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to read file")}return{content:await r.text(),path:t}},async writeFile(e,t){const r=p(e),o=await fetch("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:t})});if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to write file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?p(n.path):r}},async delete(e){const t=p(e),r=await fetch("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to delete file")}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(e,t){const r=await fetch("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:e,newPath:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to rename file")}const o=await r.json().catch(()=>({}));return{success:!!o.success,path:typeof o.path=="string"?p(o.path):t}},async revealPath(e){const t=await fetch("/api/fs/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:p(e)})});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to reveal path")}return{success:!!(await t.json().catch(()=>({}))).success}}}),W="/api/config/settings",oe="/api/config/reload",L=e=>!e||typeof e!="object"?{}:e,ne=()=>({async load(){const e=await fetch(W,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:L(await e.json().catch(()=>({}))),source:"web"}},async save(e){const t=await fetch(W,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return L(await t.json().catch(()=>({})))},async restartOpenCode(){const e=await fetch(oe,{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({error:e.statusText}));throw new Error(t.error||"Failed to restart OpenCode")}return{restarted:!0}}}),se=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),ie=async e=>{if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;try{return new Notification(e?.title??"OpenChamber",{body:e?.body,tag:e?.tag}),!0}catch(t){return console.warn("Failed to send notification",t),!1}},ae=async e=>{if(typeof window>"u")return!1;const t=window.__TAURI__;if(!t?.core?.invoke)return!1;try{return await t.core.invoke("desktop_notify",{payload:{title:e?.title,body:e?.body,tag:e?.tag}}),!0}catch(r){return console.warn("Failed to send native notification (tauri)",r),!1}},ce=()=>({async notifyAgentCompletion(e){return await ae(e)||ie(e)},canNotify:()=>typeof window<"u"&&window.__TAURI__?.core?.invoke?!0:typeof Notification<"u"?Notification.permission==="granted":!1}),le=()=>({async getAvailableTools(){const e=await fetch("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),O=async(e,t)=>{try{const r=await fetch(e,{...t,credentials:"include",headers:{Accept:"application/json",...t?.headers??{}}});return r.ok?await r.json():null}catch{return null}},ue=()=>({async getVapidPublicKey(){return O("/api/push/vapid-public-key")},async subscribe(e){return O("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async unsubscribe(e){return O("/api/push/subscribe",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async setVisibility(e){return O("/api/push/visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0})}}),f=async e=>await e.json().catch(()=>null),de=()=>({async authStatus(){const e=await fetch("/api/github/auth/status",{method:"GET",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load GitHub status");return t},async authStart(){const e=await fetch("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),t=await f(e);if(!e.ok||!t||!("deviceCode"in t))throw new Error(t?.error||e.statusText||"Failed to start GitHub auth");return t},async authComplete(e){const t=await fetch("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:e})}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to complete GitHub auth");return r},async authDisconnect(){const e=await fetch("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok)throw new Error(t?.error||e.statusText||"Failed to disconnect GitHub");return{removed:!!t?.removed}},async authActivate(e){const t=await fetch("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to activate GitHub account");return r},async me(){const e=await fetch("/api/github/me",{method:"GET",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to fetch GitHub user");return t},async prStatus(e,t,r){const o=new URLSearchParams({directory:e,branch:t,...r?{remote:r}:{}}),n=await fetch(`/api/github/pr/status?${o.toString()}`,{method:"GET",headers:{Accept:"application/json"}}),s=await f(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load PR status");return s},async prCreate(e){const t=await fetch("/api/github/pr/create",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to create PR");return r},async prUpdate(e){const t=await fetch("/api/github/pr/update",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to update PR");return r},async prMerge(e){const t=await fetch("/api/github/pr/merge",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to merge PR");return r},async prReady(e){const t=await fetch("/api/github/pr/ready",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to mark PR ready");return r},async prsList(e,t){const r=t?.page??1,o=await fetch(`/api/github/pulls/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await f(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load pull requests");return n},async prContext(e,t,r){const o=new URL("/api/github/pulls/context",window.location.origin);o.searchParams.set("directory",e),o.searchParams.set("number",String(t)),r?.includeDiff&&o.searchParams.set("diff","1"),r?.includeCheckDetails&&o.searchParams.set("checkDetails","1");const n=await fetch(o.toString(),{method:"GET",headers:{Accept:"application/json"}}),s=await f(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load pull request context");return s},async issuesList(e,t){const r=t?.page??1,o=await fetch(`/api/github/issues/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await f(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load issues");return n},async issueGet(e,t){const r=await fetch(`/api/github/issues/get?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await f(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue");return o},async issueComments(e,t){const r=await fetch(`/api/github/issues/comments?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await f(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue comments");return o}}),he=()=>({runtime:{platform:"web",isDesktop:!1,isVSCode:!1,label:"web"},terminal:ht(),git:te(),files:re(),settings:ne(),permissions:se(),notifications:ce(),github:de(),push:ue(),tools:le()});function fe(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:o,onRegistered:n,onRegisteredSW:s,onRegisterError:l}=e;let d,c;const h=async(u=!0)=>{await c};async function w(){if("serviceWorker"in navigator){if(d=await J(async()=>{const{Workbox:u}=await import("./vendor-.bun-CFSqfaPx.js").then(y=>y.eP);return{Workbox:u}},__vite__mapDeps([0,1])).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l?.(u)}),!d)return;d.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),d.addEventListener("installed",u=>{u.isUpdate||o?.()}),d.register({immediate:t}).then(u=>{s?s("/sw.js",u):n?.(u)}).catch(u=>{l?.(u)})}}return c=w(),h}window.__OPENCHAMBER_RUNTIME_APIS__=he();fe({onRegisterError(e){console.warn("[PWA] service worker registration failed:",e)}});J(()=>import("./main-WWCGfUVj.js").then(e=>e.m),__vite__mapDeps([2,0,1,3]));export{G as a,jt as b,yt as c,D as d,Lt as e,Dt as f,mt as g,me as h,ye as i,Gt as j,Et as k,R as l,Rt as m,_t as n,Zt as o,ct as p,we as q,Wt as u,_ as v};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-.bun-CbwevZxt.js","assets/vendor--DbVqbJpV.css","assets/main-De6o1hBt.js","assets/main-BV3KOtdA.css"])))=>i.map(i=>d[i]);
2
+ import{_ as J}from"./vendor-.bun-CbwevZxt.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const s of n)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function r(n){const s={};return n.integrity&&(s.integrity=n.integrity),n.referrerPolicy&&(s.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?s.credentials="include":n.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(n){if(n.ep)return;n.ep=!0;const s=r(n);fetch(n.href,s)}})();const U=1,S=1,H="/api/terminal/input-ws",Y=1200,V=1e3,X=3e4,Q=250,Z=2e4,tt=5e3,N="__openchamberTerminalInputWsState",et=new TextEncoder,rt=new TextDecoder,M=e=>{if(/^wss?:\/\//i.test(e))return e;if(/^https?:\/\//i.test(e)){const o=new URL(e);return o.protocol=o.protocol==="https:"?"wss:":"ws:",o.toString()}if(typeof window>"u")return"";const t=e.startsWith("/")?e:`/${e}`;return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${t}`},v=e=>{const t=et.encode(JSON.stringify(e)),r=new Uint8Array(t.length+1);return r[0]=U,r.set(t,1),r},B=e=>e?((e.transports??[]).includes("ws")||e.preferred==="ws")&&typeof e.ws?.path=="string"&&e.ws.path.length>0:!1;class q{socket=null;socketUrl="";boundSessionId=null;openPromise=null;reconnectTimeout=null;reconnectAttempt=0;keepaliveInterval=null;closed=!1;configure(t){if(t){if(this.socketUrl===t){if(this.closed=!1,this.isConnectedOrConnecting())return;this.ensureConnected();return}this.socketUrl=t,this.closed=!1,this.resetConnection(),this.ensureConnected()}}async sendInput(t,r){if(!t||!r||this.closed||!this.socketUrl)return!1;const o=await this.getOpenSocket(Y);if(!o||o.readyState!==S)return!1;try{return this.boundSessionId!==t&&(o.send(v({t:"b",s:t,v:1})),this.boundSessionId=t),o.send(r),!0}catch{return this.handleSocketFailure(),!1}}unbindSession(t){t&&this.boundSessionId===t&&(this.boundSessionId=null)}close(){this.closed=!0,this.clearReconnectTimeout(),this.resetConnection(),this.socketUrl=""}prime(){this.closed||!this.socketUrl||this.isConnectedOrConnecting()||this.ensureConnected()}isConnectedOrConnecting(t){return this.closed||t&&this.socketUrl!==t?!1:this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)?!0:this.openPromise!==null}sendControl(t){if(!this.socket||this.socket.readyState!==S)return!1;try{return this.socket.send(v(t)),!0}catch{return this.handleSocketFailure(),!1}}startKeepalive(){this.stopKeepalive(),this.keepaliveInterval=setInterval(()=>{this.closed||this.sendControl({t:"p",v:1})},Z)}stopKeepalive(){this.keepaliveInterval&&(clearInterval(this.keepaliveInterval),this.keepaliveInterval=null)}scheduleReconnect(){if(this.closed||!this.socketUrl||this.reconnectTimeout)return;const t=Math.min(V*Math.pow(2,this.reconnectAttempt),X),r=Math.floor(Math.random()*Q),o=t+r;this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,this.reconnectAttempt+=1,this.ensureConnected()},o)}clearReconnectTimeout(){this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null)}async getOpenSocket(t){if(this.socket&&this.socket.readyState===S)return this.socket;if(this.ensureConnected(),this.socket&&this.socket.readyState===S)return this.socket;const r=await Promise.race([this.openPromise??Promise.resolve(null),new Promise(o=>{setTimeout(()=>o(null),t)})]);return r&&r.readyState===S?r:this.socket&&this.socket.readyState===S?this.socket:null}ensureConnected(){this.closed||!this.socketUrl||this.socket&&(this.socket.readyState===WebSocket.OPEN||this.socket.readyState===WebSocket.CONNECTING)||this.openPromise||(this.clearReconnectTimeout(),this.openPromise=new Promise(t=>{let r=!1,o=null;const n=s=>{r||(r=!0,o&&(clearTimeout(o),o=null),this.openPromise=null,t(s))};try{const s=new WebSocket(this.socketUrl);s.binaryType="arraybuffer",s.onopen=()=>{this.socket=s,this.reconnectAttempt=0,this.startKeepalive(),n(s)},s.onmessage=l=>{this.handleSocketMessage(l.data)},s.onclose=()=>{this.socket===s&&(this.socket=null,this.boundSessionId=null,this.stopKeepalive(),this.closed||this.scheduleReconnect()),n(null)},this.socket=s,o=setTimeout(()=>{s.readyState===WebSocket.CONNECTING&&(s.close(),n(null))},tt)}catch{n(null),this.closed||this.scheduleReconnect()}}))}async handleSocketMessage(t){const r=await this.asUint8Array(t);if(!(!r||r.length<2)&&r[0]===U)try{const o=JSON.parse(rt.decode(r.subarray(1)));if(o.t==="po")return;o.t==="e"&&((o.c==="NOT_BOUND"||o.c==="SESSION_NOT_FOUND")&&(this.boundSessionId=null),o.f===!0&&this.handleSocketFailure())}catch{this.handleSocketFailure()}}async asUint8Array(t){if(t instanceof ArrayBuffer)return new Uint8Array(t);if(t instanceof Uint8Array)return t;if(typeof Blob<"u"&&t instanceof Blob){const r=await t.arrayBuffer();return new Uint8Array(r)}return null}handleSocketFailure(){this.boundSessionId=null,this.resetConnection(),this.scheduleReconnect()}resetConnection(){if(this.openPromise=null,this.stopKeepalive(),this.socket){const t=this.socket;this.socket=null,t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close()}this.boundSessionId=null}}const g=()=>{const e=globalThis;return e[N]||(e[N]={capability:null,manager:null}),e[N]},z=e=>{const t=g();if(t.capability=e??null,!B(t.capability)){t.manager?.close(),t.manager=null;return}const r=t.capability?.ws?.path;if(!r)return;const o=M(r);o&&(t.manager||(t.manager=new q),t.manager.configure(o))},ot=async(e,t)=>{const r=await fetch(`/api/terminal/${e}/input`,{method:"POST",headers:{"Content-Type":"text/plain"},body:t});if(!r.ok){const o=await r.json().catch(()=>({error:"Failed to send input"}));throw new Error(o.error||"Failed to send terminal input")}};async function nt(e){const t=await fetch("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e.cwd,cols:e.cols||80,rows:e.rows||24})});if(!t.ok){const o=await t.json().catch(()=>({error:"Failed to create terminal"}));throw new Error(o.error||"Failed to create terminal session")}const r=await t.json();return z(r.capabilities?.input),r}function st(e,t,r,o={}){const{maxRetries:n=3,initialRetryDelay:s=1e3,maxRetryDelay:l=8e3,connectionTimeout:d=1e4}=o;let c=null,h=0,w=null,u=null,y=!1,T=!1,b=!1;const C=()=>{w&&(clearTimeout(w),w=null),u&&(clearTimeout(u),u=null)},P=()=>{y=!0,C(),c&&(c.close(),c=null)},F=()=>{if(!(y||b)){if(c&&c.readyState!==EventSource.CLOSED){console.warn("Attempted to create duplicate EventSource, skipping");return}T=!1,c=new EventSource(`/api/terminal/${e}/stream`),u=setTimeout(()=>{!T&&c?.readyState!==EventSource.OPEN&&(console.error("Terminal connection timeout"),c?.close(),x(new Error("Connection timeout"),!1))},d),c.onopen=()=>{T||(T=!0,h=0,C(),t({type:"connected"}))},c.onmessage=E=>{try{const m=JSON.parse(E.data);m.type==="exit"&&(g().manager?.unbindSession(e),b=!0,P()),t(m)}catch(m){console.error("Failed to parse terminal event:",m),r?.(m,!1)}},c.onerror=E=>{console.error("Terminal stream error:",E,"readyState:",c?.readyState),C();const m=b||c?.readyState===EventSource.CLOSED;c?.close(),c=null,b||x(new Error("Terminal stream connection error"),m)}}},x=(E,m)=>{if(!(y||b))if(h<n&&!m){h++;const I=Math.min(s*Math.pow(2,h-1),l);console.log(`Reconnecting to terminal stream (attempt ${h}/${n}) in ${I}ms`),t({type:"reconnecting",attempt:h,maxAttempts:n}),w=setTimeout(()=>{!y&&!b&&F()},I)}else console.error(`Terminal connection failed after ${h} attempts`),r?.(E,!0),P()};return F(),P}async function it(e,t){const r=g();r.manager&&await r.manager.sendInput(e,t)||await ot(e,t)}async function at(e,t,r){const o=await fetch(`/api/terminal/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:t,rows:r})});if(!o.ok){const n=await o.json().catch(()=>({error:"Failed to resize terminal"}));throw new Error(n.error||"Failed to resize terminal")}}async function ct(e){g().manager?.unbindSession(e);const t=await fetch(`/api/terminal/${e}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to close terminal"}));throw new Error(r.error||"Failed to close terminal")}}async function lt(e,t){g().manager?.unbindSession(e);const r=await fetch(`/api/terminal/${e}/restart`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:t.cwd,cols:t.cols??80,rows:t.rows??24})});if(!r.ok){const n=await r.json().catch(()=>({error:"Failed to restart terminal"}));throw new Error(n.error||"Failed to restart terminal")}const o=await r.json();return z(o.capabilities?.input),o}async function ut(e){const t=await fetch("/api/terminal/force-kill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:"Failed to force kill terminal"}));throw new Error(r.error||"Failed to force kill terminal")}e.sessionId&&g().manager?.unbindSession(e.sessionId)}function we(){const e=g();if(e.capability&&!B(e.capability))return;const t=e.capability?.ws?.path??H,r=M(t);r&&(e.manager||(e.manager=new q),!e.manager.isConnectedOrConnecting(r)&&(e.manager.configure(r),e.manager.prime()))}const dt=e=>{const t=e?.retry;return{maxRetries:t?.maxRetries??3,initialRetryDelay:t?.initialDelayMs??1e3,maxRetryDelay:t?.maxDelayMs??8e3,connectionTimeout:e?.connectionTimeoutMs??1e4}},ht=()=>({async createSession(e){return nt(e)},connect(e,t,r){const o=st(e,t.onEvent,t.onError,dt(r));return{close:()=>o()}},async sendInput(e,t){await it(e,t)},async resize(e){await at(e.sessionId,e.cols,e.rows)},async close(e){await ct(e)},async restartSession(e,t){return lt(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows})},async forceKill(e){await ut(e)}}),ft=()=>{if(typeof window>"u")return"";const e=window.__OPENCHAMBER_DESKTOP_SERVER__?.origin;return e||window.location.origin},i="/api/git",pt=1200,wt=5e3,A=new Map,k=new Map,$=new Map,j=new Map,K=e=>e.trim();function a(e,t,r){const o=new URL(e,ft());if(t&&o.searchParams.set("directory",t),r)for(const[n,s]of Object.entries(r))s!==void 0&&o.searchParams.set(n,String(s));return o.toString()}async function yt(e){const t=K(e),r=Date.now(),o=$.get(t);if(o&&o.expiresAt>r)return o.value;const n=j.get(t);if(n)return n;const s=(async()=>{const l=await fetch(a(`${i}/check`,e));if(!l.ok)throw new Error(`Failed to check git repository: ${l.statusText}`);const c=!!(await l.json()).isGitRepository;return $.set(t,{value:c,expiresAt:Date.now()+wt}),c})();j.set(t,s);try{return await s}finally{j.get(t)===s&&j.delete(t)}}async function mt(e){const t=K(e),r=Date.now(),o=A.get(t);if(o&&o.expiresAt>r)return o.value;const n=k.get(t);if(n)return n;const s=(async()=>{const l=await fetch(a(`${i}/status`,e));if(!l.ok)throw new Error(`Failed to get git status: ${l.statusText}`);const d=await l.json();return A.set(t,{value:d,expiresAt:Date.now()+pt}),d})();k.set(t,s);try{return await s}finally{k.get(t)===s&&k.delete(t)}}async function gt(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const s=await fetch(a(`${i}/diff`,e,{path:r,staged:o?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function Tt(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await fetch(a(`${i}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function bt(e,t){if(!t)throw new Error("path is required to revert git changes");const r=await fetch(a(`${i}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert git changes")}}async function St(e){if(!e)return!1;const t=await fetch(a(`${i}/worktree-type`,e));if(!t.ok)throw new Error(`Failed to detect worktree type: ${t.statusText}`);return!!(await t.json()).linked}async function Et(e){const t=await fetch(a(`${i}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function kt(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await fetch(a(`${i}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function jt(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await fetch(a(`${i}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function Ot(e,t){const r=t?.remote?.trim();if(!r)throw new Error("remote is required to remove a remote");const o=await fetch(a(`${i}/remotes`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to remove remote")}return o.json()}async function Ct(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error("No files provided to generate commit message");const o={files:t};r?.zenModel&&(o.zenModel=r.zenModel),r?.providerId&&(o.providerId=r.providerId),r?.modelId&&(o.modelId=r.modelId);const n=await fetch(a(`${i}/commit-message`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!n.ok){const c=await n.json().catch(()=>({error:n.statusText}));console.error("[git-generation][browser] http error",{status:n.status,statusText:n.statusText,error:c});const h=typeof c?.traceId=="string"&&c.traceId?` (traceId: ${c.traceId})`:"";throw new Error(`${c.error||"Failed to generate commit message"}${h}`)}const s=await n.json();if(!s?.message||typeof s.message!="object")throw new Error("Malformed commit generation response");const l=typeof s.message.subject=="string"&&s.message.subject.trim().length>0?s.message.subject.trim():"",d=Array.isArray(s.message.highlights)?s.message.highlights.filter(c=>typeof c=="string"&&c.trim().length>0).map(c=>c.trim()):[];return{message:{subject:l,highlights:d}}}async function Pt(e,t){const{base:r,head:o,context:n,zenModel:s,providerId:l,modelId:d}=t;if(!r||!o)throw new Error("base and head are required");const c={base:r,head:o};n?.trim()&&(c.context=n.trim()),s&&(c.zenModel=s),l&&(c.providerId=l),d&&(c.modelId=d);const h=await fetch(a(`${i}/pr-description`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!h.ok){const T=await h.json().catch(()=>({error:h.statusText}));throw new Error(T.error||"Failed to generate PR description")}const w=await h.json().catch(()=>null),u=typeof w?.title=="string"?w.title:"",y=typeof w?.body=="string"?w.body:"";if(!u&&!y)throw new Error("Malformed PR description response");return{title:u,body:y}}async function R(e){const t=await fetch(a(`${i}/worktrees`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list worktrees")}return t.json()}async function _(e,t){const r=await fetch(a(`${i}/worktrees/validate`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to validate worktree")}return r.json()}async function G(e,t){const r=await fetch(a(`${i}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to create worktree")}return r.json()}async function D(e,t){const r=await fetch(a(`${i}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete worktree")}return r.json()}async function Nt(e,t,r={}){const o=await fetch(a(`${i}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create commit")}return o.json()}async function Ft(e,t={}){const r=await fetch(a(`${i}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to push")}return r.json()}async function xt(e,t={}){const r=await fetch(a(`${i}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to pull")}return r.json()}async function It(e,t={}){const r=await fetch(a(`${i}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to fetch")}return r.json()}async function vt(e,t){const r=await fetch(a(`${i}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout branch")}return r.json()}async function At(e,t,r){const o=await fetch(a(`${i}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function $t(e,t,r){const o=await fetch(a(`${i}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function Rt(e,t={}){const r=await fetch(a(`${i}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file}));if(!r.ok)throw new Error(`Failed to get git log: ${r.statusText}`);return r.json()}async function _t(e,t){const r=await fetch(a(`${i}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function Gt(){const e=await fetch(a(`${i}/identities`,void 0));if(!e.ok)throw new Error(`Failed to get git identities: ${e.statusText}`);return e.json()}async function Dt(e){const t=await fetch(a(`${i}/identities`,void 0),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to create git identity")}return t.json()}async function Wt(e,t){const r=await fetch(a(`${i}/identities/${e}`,void 0),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to update git identity")}return r.json()}async function Lt(e){const t=await fetch(a(`${i}/identities/${e}`,void 0),{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to delete git identity")}}async function Jt(e){if(!e)return null;const t=await fetch(a(`${i}/current-identity`,e));if(!t.ok)throw new Error(`Failed to get current git identity: ${t.statusText}`);const r=await t.json();return r?{userName:r.userName??null,userEmail:r.userEmail??null,sshCommand:r.sshCommand??null}:null}async function Ut(e){if(!e)return!1;const t=await fetch(a(`${i}/has-local-identity`,e));if(!t.ok)throw new Error(`Failed to check local identity: ${t.statusText}`);return(await t.json().catch(()=>null))?.hasLocalIdentity===!0}async function ye(){const e=await fetch(a(`${i}/global-identity`,void 0));if(!e.ok)throw new Error(`Failed to get global git identity: ${e.statusText}`);const t=await e.json();return!t||!t.userName&&!t.userEmail?null:{userName:t.userName??null,userEmail:t.userEmail??null,sshCommand:t.sshCommand??null}}async function Mt(e,t){const r=await fetch(a(`${i}/set-identity`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to set git identity")}return r.json()}async function me(){const e=await fetch(a(`${i}/discover-credentials`,void 0));if(!e.ok)throw new Error(`Failed to discover git credentials: ${e.statusText}`);return e.json()}async function Bt(e){const t=await fetch(a(`${i}/remotes`,e));if(!t.ok)throw new Error(`Failed to get remotes: ${t.statusText}`);return t.json()}async function qt(e,t){const r=await fetch(a(`${i}/rebase`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to rebase")}return r.json()}async function zt(e){const t=await fetch(a(`${i}/rebase/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort rebase")}return t.json()}async function Kt(e,t){const r=await fetch(a(`${i}/merge`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to merge")}return r.json()}async function Ht(e){const t=await fetch(a(`${i}/merge/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort merge")}return t.json()}async function Yt(e){const t=await fetch(a(`${i}/rebase/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue rebase")}return t.json()}async function Vt(e){const t=await fetch(a(`${i}/merge/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue merge")}return t.json()}async function Xt(e,t){const r=await fetch(a(`${i}/stash`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t||{})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to stash")}return r.json()}async function Qt(e){const t=await fetch(a(`${i}/stash/pop`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to pop stash")}return t.json()}async function Zt(e){const t=await fetch(a(`${i}/conflict-details`,e));if(!t.ok)throw new Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}const te=()=>({checkIsGitRepository:yt,getGitStatus:mt,getGitDiff:gt,getGitFileDiff:Tt,revertGitFile:bt,isLinkedWorktree:St,getGitBranches:Et,deleteGitBranch:kt,deleteRemoteBranch:jt,removeRemote:Ot,generateCommitMessage:Ct,generatePullRequestDescription:Pt,listGitWorktrees:R,validateGitWorktree:_,createGitWorktree:G,deleteGitWorktree:D,createGitCommit(e,t,r){return Nt(e,t,r)},gitPush:Ft,gitPull:xt,gitFetch:It,checkoutBranch:vt,createBranch:At,renameBranch:$t,getGitLog(e,t){return Rt(e,t)},getCommitFiles:_t,getCurrentGitIdentity:Jt,hasLocalIdentity:Ut,setGitIdentity:Mt,getGitIdentities:Gt,createGitIdentity:Dt,updateGitIdentity:Wt,deleteGitIdentity:Lt,getRemotes:Bt,rebase:qt,abortRebase:zt,continueRebase:Yt,merge:Kt,abortMerge:Ht,continueMerge:Vt,stash:Xt,stashPop:Qt,getConflictDetails:Zt,worktree:{list:R,validate:_,create:G,remove:D}}),p=e=>e.replace(/\\/g,"/"),ee=(e,t)=>{const r=p(t?.directory||t?.path||e),o=Array.isArray(t?.entries)?t.entries:[];return{directory:r,entries:o.filter(n=>!!(n&&typeof n.name=="string"&&typeof n.path=="string")).map(n=>({name:n.name,path:p(n.path),isDirectory:!!n.isDirectory}))}},re=()=>({async listDirectory(e){const t=p(e),r=new URLSearchParams;t&&r.set("path",t);const o=await fetch(`/api/fs/list${r.toString()?`?${r.toString()}`:""}`);if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to list directory")}const n=await o.json();return ee(t,n)},async search(e){const t=new URLSearchParams,r=p(e.directory);r&&t.set("directory",r),t.set("query",e.query),t.set("dirs","false"),t.set("type","file"),typeof e.maxResults=="number"&&Number.isFinite(e.maxResults)&&t.set("limit",String(e.maxResults));const o=await fetch(`/api/find/file?${t.toString()}`);if(!o.ok){const l=await o.json().catch(()=>({error:o.statusText}));throw new Error(l.error||"Failed to search files")}const n=await o.json();return(Array.isArray(n)?n:[]).map(l=>({path:p(`${r}/${l}`),preview:[p(l)]}))},async createDirectory(e){const t=p(e),r=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to create directory")}const o=await r.json();return{success:!!o?.success,path:typeof o?.path=="string"?p(o.path):t}},async readFile(e){const t=p(e),r=await fetch(`/api/fs/read?path=${encodeURIComponent(t)}`);if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to read file")}return{content:await r.text(),path:t}},async writeFile(e,t){const r=p(e),o=await fetch("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:t})});if(!o.ok){const s=await o.json().catch(()=>({error:o.statusText}));throw new Error(s.error||"Failed to write file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?p(n.path):r}},async delete(e){const t=p(e),r=await fetch("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to delete file")}return{success:!!(await r.json().catch(()=>({}))).success}},async rename(e,t){const r=await fetch("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:e,newPath:t})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to rename file")}const o=await r.json().catch(()=>({}));return{success:!!o.success,path:typeof o.path=="string"?p(o.path):t}},async revealPath(e){const t=await fetch("/api/fs/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:p(e)})});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to reveal path")}return{success:!!(await t.json().catch(()=>({}))).success}}}),W="/api/config/settings",oe="/api/config/reload",L=e=>!e||typeof e!="object"?{}:e,ne=()=>({async load(){const e=await fetch(W,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:L(await e.json().catch(()=>({}))),source:"web"}},async save(e){const t=await fetch(W,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return L(await t.json().catch(()=>({})))},async restartOpenCode(){const e=await fetch(oe,{method:"POST"});if(!e.ok){const t=await e.json().catch(()=>({error:e.statusText}));throw new Error(t.error||"Failed to restart OpenCode")}return{restarted:!0}}}),se=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),ie=async e=>{if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;try{return new Notification(e?.title??"OpenChamber",{body:e?.body,tag:e?.tag}),!0}catch(t){return console.warn("Failed to send notification",t),!1}},ae=async e=>{if(typeof window>"u")return!1;const t=window.__TAURI__;if(!t?.core?.invoke)return!1;try{return await t.core.invoke("desktop_notify",{payload:{title:e?.title,body:e?.body,tag:e?.tag}}),!0}catch(r){return console.warn("Failed to send native notification (tauri)",r),!1}},ce=()=>({async notifyAgentCompletion(e){return await ae(e)||ie(e)},canNotify:()=>typeof window<"u"&&window.__TAURI__?.core?.invoke?!0:typeof Notification<"u"?Notification.permission==="granted":!1}),le=()=>({async getAvailableTools(){const e=await fetch("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),O=async(e,t)=>{try{const r=await fetch(e,{...t,credentials:"include",headers:{Accept:"application/json",...t?.headers??{}}});return r.ok?await r.json():null}catch{return null}},ue=()=>({async getVapidPublicKey(){return O("/api/push/vapid-public-key")},async subscribe(e){return O("/api/push/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async unsubscribe(e){return O("/api/push/subscribe",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})},async setVisibility(e){return O("/api/push/visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:!0})}}),f=async e=>await e.json().catch(()=>null),de=()=>({async authStatus(){const e=await fetch("/api/github/auth/status",{method:"GET",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load GitHub status");return t},async authStart(){const e=await fetch("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),t=await f(e);if(!e.ok||!t||!("deviceCode"in t))throw new Error(t?.error||e.statusText||"Failed to start GitHub auth");return t},async authComplete(e){const t=await fetch("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:e})}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to complete GitHub auth");return r},async authDisconnect(){const e=await fetch("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok)throw new Error(t?.error||e.statusText||"Failed to disconnect GitHub");return{removed:!!t?.removed}},async authActivate(e){const t=await fetch("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:e})}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to activate GitHub account");return r},async me(){const e=await fetch("/api/github/me",{method:"GET",headers:{Accept:"application/json"}}),t=await f(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to fetch GitHub user");return t},async prStatus(e,t,r){const o=new URLSearchParams({directory:e,branch:t,...r?{remote:r}:{}}),n=await fetch(`/api/github/pr/status?${o.toString()}`,{method:"GET",headers:{Accept:"application/json"}}),s=await f(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load PR status");return s},async prCreate(e){const t=await fetch("/api/github/pr/create",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to create PR");return r},async prUpdate(e){const t=await fetch("/api/github/pr/update",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to update PR");return r},async prMerge(e){const t=await fetch("/api/github/pr/merge",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to merge PR");return r},async prReady(e){const t=await fetch("/api/github/pr/ready",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)}),r=await f(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to mark PR ready");return r},async prsList(e,t){const r=t?.page??1,o=await fetch(`/api/github/pulls/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await f(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load pull requests");return n},async prContext(e,t,r){const o=new URL("/api/github/pulls/context",window.location.origin);o.searchParams.set("directory",e),o.searchParams.set("number",String(t)),r?.includeDiff&&o.searchParams.set("diff","1"),r?.includeCheckDetails&&o.searchParams.set("checkDetails","1");const n=await fetch(o.toString(),{method:"GET",headers:{Accept:"application/json"}}),s=await f(n);if(!n.ok||!s)throw new Error(s?.error||n.statusText||"Failed to load pull request context");return s},async issuesList(e,t){const r=t?.page??1,o=await fetch(`/api/github/issues/list?directory=${encodeURIComponent(e)}&page=${encodeURIComponent(String(r))}`,{method:"GET",headers:{Accept:"application/json"}}),n=await f(o);if(!o.ok||!n)throw new Error(n?.error||o.statusText||"Failed to load issues");return n},async issueGet(e,t){const r=await fetch(`/api/github/issues/get?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await f(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue");return o},async issueComments(e,t){const r=await fetch(`/api/github/issues/comments?directory=${encodeURIComponent(e)}&number=${encodeURIComponent(String(t))}`,{method:"GET",headers:{Accept:"application/json"}}),o=await f(r);if(!r.ok||!o)throw new Error(o?.error||r.statusText||"Failed to load issue comments");return o}}),he=()=>({runtime:{platform:"web",isDesktop:!1,isVSCode:!1,label:"web"},terminal:ht(),git:te(),files:re(),settings:ne(),permissions:se(),notifications:ce(),github:de(),push:ue(),tools:le()});function fe(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:o,onRegistered:n,onRegisteredSW:s,onRegisterError:l}=e;let d,c;const h=async(u=!0)=>{await c};async function w(){if("serviceWorker"in navigator){if(d=await J(async()=>{const{Workbox:u}=await import("./vendor-.bun-CbwevZxt.js").then(y=>y.eR);return{Workbox:u}},__vite__mapDeps([0,1])).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l?.(u)}),!d)return;d.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),d.addEventListener("installed",u=>{u.isUpdate||o?.()}),d.register({immediate:t}).then(u=>{s?s("/sw.js",u):n?.(u)}).catch(u=>{l?.(u)})}}return c=w(),h}window.__OPENCHAMBER_RUNTIME_APIS__=he();fe({onRegisterError(e){console.warn("[PWA] service worker registration failed:",e)}});J(()=>import("./main-De6o1hBt.js").then(e=>e.m),__vite__mapDeps([2,0,1,3]));export{G as a,jt as b,yt as c,D as d,Lt as e,Dt as f,mt as g,me as h,ye as i,Gt as j,Et as k,R as l,Rt as m,_t as n,Zt as o,ct as p,we as q,Wt as u,_ as v};